0
votes

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

1
"this does not work" isn't very descriptive. In addition to telling us what you want or expect to happen, please tell us what actually happens. Also, please format samples. You can indent lines four spaces (the "101\n010" button will do this for you) to format text as code or use ">" to quote text. Please edit your question (click the "edit" link underneath it) and format your sample .htaccess. For other formatting tips, click the orange question mark in the text editor toolbar. - outis

1 Answers

0
votes

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