-2
votes

Possible Duplicate:
How to remove action name from url in cakephp?

I am using cakephp to develop my website in Cakephp and I would like to remove action(or view )name from the application URL what should I do fro that. My requirement is I want to add the parameters in place of view name recently my URL is like:

"domainname/controllername/viewname/param1/param2"

but I need

"Domainname/controllername/param1/param2"

My .htaccess files are like below

.htaccess in root folder

<IfModule mod_rewrite.c>
   RewriteEngine on 
   RewriteRule    ^$     [L]
   RewriteRule    (.*) app/webroot/index.php/$1 [L]
</IfModule>

.htaccess in app folder

 <IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /liberty_new/app/
  RewriteRule    ^$    webroot/index.php/    [L]
  RewriteRule    (.*) webroot/index.php/$1    [L]
 </IfModule>

.htaccess in webroot folder

<IfModule mod_rewrite.c>
 RewriteEngine ON
 RewriteBase /
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^(.*)$ /$1 [QSA,L]
</IfModule>
1

1 Answers

1
votes

You do this in your Config\routes.php file. Set the Router params to write the URL as you need. Do not edit your htaccess files or it can/will break CakePHP routing.

Router::connect('/:controller/:param1/:param2', array('action' => 'index'), array('param1' => '[a-zA-Z0-9]+', 'param2' => '[a-zA-Z0-9]+'));

This should send all requestes to any controller to the index function of that controller and pass params 1 and 2. Of course, this can be heavily customized. I would strongly suggest you read about routing in the documentation and never alter htaccess unless you have to.

http://book.cakephp.org/2.0/en/development/routing.html#routes-configuration