routes - cakephp routing retrieve parameter from url to redirect -
i using cakephp v2.3.8 , struggle bit routing.
the old url www.domain.com/properties.aspx?prop=1999
want route properties controller id = 1999 url like: www.domain.com/properties/view/1999
in routes.php strip .aspx out of url struggle last bit.
router::parseextensions('htm','html','aspx');
this how close am:
router::connect('/properties', array('controller' => 'properties', 'action' => 'view', ??? '));
this view function in propertiescontroller.php
public function view($id = null) { if (!$this->property->exists($id)) { throw new notfoundexception(__('sorry, couldn\'t find looking for...')); } $options = array('conditions' => array('property.' . $this->property->primarykey => $id)); $propdata = $this->property->find('first', $options); $this->set('property', $propdata); }
this works perfect within website, not mentioned, redirected www.domain.com/properties
this .htaccess file in public_html folder.
rewriteengine on rewritebase / rewritecond %{http_host} !^www\. [nc] rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l] rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.*)$ index.php [qsa,l]
thanks looking this.
file structure:
.htaccess [1] /app/.htaccess [2] /lib/cake/ /public_html/.htaccess [3] /plugins/ /vendors/
[1]
<ifmodule mod_rewrite.c> rewriteengine on rewriterule ^$ app/webroot/ [l] rewriterule (.*) app/webroot/$1 [l] </ifmodule>
[2]
<ifmodule mod_rewrite.c> rewriteengine on rewriterule ^$ webroot/ [l] rewriterule (.*) webroot/$1 [l] </ifmodule>
[3]
rewriteengine on rewritebase / rewritecond %{http_host} !^www\. [nc] rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l] rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.*)$ index.php [qsa,l] /public_html/index.php if (!defined('root')) { define('root', ds.'home'.ds. 'user'); } /** * actual directory name "app". * */ if (!defined('app_dir')) { define('app_dir', 'app'); }
nick think problem due .htaccess file
you have setup cakephp in public_html think have replaced .htaccess file of cakephp contains code like:
<ifmodule mod_rewrite.c> rewriteengine on rewriterule ^$ app/webroot/ [l] rewriterule (.*) app/webroot/$1 [l] </ifmodule>
place .htaccess file @ out side app folder,means in publich_html folder
Comments
Post a Comment