2014-11-08 125 views
2

我有一個URL www.domain.com/example,我將其更改爲www.domain.com/example2/example3。它工作正常。但是當我手動訪問舊的URL時,它是可訪問的,但我需要的是它應該被重定向到新的URL。Cakephp URL重寫和重定向

回答

0

做到這一點最簡單的方法就是例子

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteRule (.*) http://domain.com/example2/example3 [R] 
</IfModule> 

並刪除所有例子代碼在.htaccess文件。

0

TRY:

如果www.domain.com/example使用控制器=>示例和動作

=> 索引

然後使用:

Router::redirect(
    '/example1/example2/*', 
    array('controller' => 'example', 'action' => 'index'), 
    array('persist' => true) 
);