Reputation: 380
I have bunch of old website URLs that are I am trying to redirect to new destination , right now I am trying to remove query string from old URLS and then redirect to new URL with its parameters like
Previous: www.domain.com/ranges.php?reqinfo=some-data-info
Required: www.domain.com/info/ranges/some-data-info
I am trying this in .htaccess
RewriteCond %{QUERY_STRING} ^\ranges\.php\?reqinfo=(.*)$ [NC]
RewriteRule ^info/ranges/%1? [L,R=301]
I have also tried one other rule but it also remove all peramaters as well
RewriteRule ^ranges\.php$ /info/ranges/$1? [L,R=301]
can someone please help.
Upvotes: 2
Views: 186
Reputation: 784998
ranges.php
is part of your REQUEST_URI hence you cannot match in using QUERY_STRING
condition. Use it as:
RewriteCond %{QUERY_STRING} ^reqinfo=([^&]+) [NC]
RewriteRule ^ranges\.php$ /info/ranges/%1? [L,R=301,NC]
Upvotes: 1