简体   繁体   中英

URL rewrite rules not working using .htaccess on cakephp

I was using cakephp 1.2 and recently i updated cake version and migrated to 2.4.

Before we were using many .htaccess rules for applications . We write them in /webroot/.htaccess file . But after the migration to 2.4 , any rules are not working .

EG

RewriteCond %{REQUEST_FILENAME} -d

RewriteCond %{REQUEST_URI} /news/$

RewriteRule ^(.*)$ pages/news/ [QSA,L]

But this rules not working on cake 2.4. Can Anybody help me to solve this issues?

Your best option is probably to not use the mod_rewrite rules but to use the Router class instead.

If you edit the file app/config/routes.php and add a route like this (Assuming you want to call PagesController::display('news') ):

Router::connect('/news/*', array(
    'controller' => 'pages',
    'action' => 'display', 
    'news'
));

You should get the same result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM