I am switching CMS and have about 600 URLs that need to get redirected to the new scheme. The URL on the old site looks like the following on my test server:
www.example.us/?p=100&option=com_wordpress&Itemid=619
The new URL scheme will exist as:
www.example.us/blog.php?p=100
Some old URLs use p=, others id= or catid=. I have tried various redirects like the following, all failing for various reasons:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^p=100
RewriteRule .* 100.php
The result is that it redirect to 100.php but appends the query string to the url and ends up like:
example.us/100.php?p=100&option=com_wordpress&Itemid=619
That is the closest to a solution. I have also tried the following with the failure message noted below:
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^p=100
RewriteRule ^(.*)$ 100.php
# Fails as it appends query string
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^p=100
RewriteRule .* 100.php$
# Fails with The requested URL /100.php$ was not found on this server.
RewriteEngine on
RewriteCond %{QUERY_STRING} ^p=100$
RewriteRule ^index\.php$ 100.php [L,R=301]
# Fails redirecting to /index.html
RewriteRule p=100 100.php [R=301,L]
# Fails redirecting to /index.html
RewriteRule ^p=100$ 100.php [R=301,L]
# Fails redirecting to /index.html
I tried many of the above with/without http:// preceding the redirect to URL.
/p=NNN
maps toNNN.php
- however, this does not correlate to the URL example at the top (wherep=100
seems to map toblog.php?p=2792
)? Isp=NNN
(orid=
orcatid=
) the only part of the old URL that matters?