Reputation: 55
I had an URL www.domain.com/example and I changed it to www.domain.com/example2/example3. It is working fine. But when I manually access old URL, it is accessible but what I need is it should be redirected to new URL.
Upvotes: 2
Views: 110
Reputation: 714
TRY:
if www.domain.com/example uses controller => example and action => index
then use:
Router::redirect(
'/example1/example2/*',
array('controller' => 'example', 'action' => 'index'),
array('persist' => true)
);
Upvotes: 0
Reputation: 7525
Router::redirect(
'/example',
'/example2/example3',
array('persist' => true)
);
http://book.cakephp.org/2.0/en/development/routing.html#redirect-routing
http://api.cakephp.org/2.4/class-Router.html#_redirect
Upvotes: 2
Reputation: 1451
The easiest way to do it is a .htaccess file in example
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule (.*) http://domain.com/example2/example3 [R]
</IfModule>
And remove all your code from example.
Upvotes: 0