Monday, June 7, 2010

URL Rewrite for alias with parameter

When we need to redirect certain alias to another url,
we can modify htaccess file to handle redirection with the code below:

Example: redirect blabla to /articles/index
RewriteRule ^blabla(/)? /articles/index$1 [R,L]
The above work if our url goes:
http://www.example.com/blabla or http://www.example.com/blabla/

If we may have sub folders within bla bla or need to pass in additional parameter (as common in zend framework):
RewriteRule ^blabla(/)?(.+)? /articles/index$1$2 [R,L]
The above work if our url goes:
http://www.example.com/blabla/page/2/xyz/aaa
to
http://www.example.com/articles/index/page/2/xyz/aaa


No comments: