Apache mod_rewrite, URL rewrite and then redirect problem
I am having a problem with mod_rewrite. I want to do this:
i have urls in the form of mydomain.com/index.php/tag/123/some-name/
i want to change this url to mydomain.com/some-name/
i have written below code in my .htacess file and this does not work :-(
first rewrite
RewriteCond %{THE_REQUEST} ^/index.php/tag/(.)/$ [NC] RewriteRule ^index.php/tag/([0-9]+)/(.)/$开发者_运维百科 /$2/ [R=301,L]
then redirect to index.phe
RewriteRule ^(.*)/$ /index.php?tagname=$1 [L]
my urls are not getting re-written in browser nor did it goes to index.php.
Thanks in advance, Ravi
If the tag number is required to access the correct page, you will have to do more than use mod_rewrite...
Otherwise, this is what you are looking for:
RewriteRule ^index.php/tag/[0-9]+/(.*)$ $1 [R]
RewriteRule ^(.*)$ index.php?tagname=$1 [L]
Now someone visiting: mydomain.com/tag/123/wierdtagname will get redirected to mydomain.com/wierdtagname which will run mydomain.com/index.php?tagname=wierdtagname
精彩评论