Reputation: 21
I have old site with hundreds URL that look like that:
http:www.domain.com/Contact.asp?Pid=344
http:www.domain.com/Contact.asp?Pid=345
http:www.domain.com/Contact.asp?Pid=346
and so on ...
I need to move all of them permanent to 1 single URL :
http:www.domain.com/contact
I tried this:
RewriteCond %{QUERY_STRING} Contact.asp?Pid=([0-999]+)
RewriteRule ^http://www.domain.com/contact? [L,R=301]
But it doesn't work well.
The old site use ASP
. The new site build on Joomla
. The domain will be the domain from old site
Upvotes: 2
Views: 166
Reputation: 143886
You're close. You need to use the %{QUERY_STRING}
variable like you did, but the var doesn't include the URI-path (the Contact.asp?
) part. Also, your RewriteRule
is missing a regex pattern. Try:
RewriteCond %{QUERY_STRING} Pid=([0-999]+)
RewriteRule ^/?Contact\.asp$ http://www.domain.com/contact? [L,R=301]
Upvotes: 1
Reputation: 85
Are the only pages you have on there the contact pages? You could just 301 the entire directory since they are all moving to one URL.
RewriteEngine on
RewriteBase /
RewriteRule ^/(.*)$ http://www.domain.com/$1 [R=301,L]
Upvotes: 0