Reputation: 13
I 'm having a problem when trying to redirect to rewritten url. I'm rewrite from :
www.testdomain.com/index.php?rt=..&id=..
to :
www.testdomain.com/{rt}/{id}
and trying to redirect from the old (1) to (2).
Here, my .htaccess file:
RewriteRule ^(.*)/([0-9]+)/?$ index.php?rt=$1&id=$2 [L]
RewriteCond %{REQUEST_URI} ^/index.php
RewriteCond %{QUERY_STRING} ^rt=(.*)&id=(.*)$
RewriteRule ^(.*)$ http://www.localdomain.com/%1/%2? [R=301,L]
And this is my problem: When I'm run in browser, It throw an error about redirect loop. But I don't know how to fix this error.
Upvotes: 1
Views: 60
Reputation: 785128
Replace your code with:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?rt=([^\s&]+)&id=([^\s&]+) [NC]
RewriteRule ^ /%1/%2? [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([0-9]+)/?$ /index.php?rt=$1&id=$2 [L,QSA]
Upvotes: 1