1

This is really bugging me, I have followed a few tutorials but just can't get anywhere. I'm trying to do a 301 redirect from:

/webpage-mackay.php?wp=Mission

to:

http://domain.org.au/webpage.php?wp=Mackay%20Mission

I have attempted writing like this:

RewriteCond %{QUERY_STRING} ^wp=Mission$
RewriteRule ^/webpage-mackay\.php$ http://domain.org.au/webpage.php?wp=Mackay%20Mission [R=301,L]

and:

RewriteCond   %{REQUEST_URI}    ^/webpage-mackay.php$
RewriteCond   %{QUERY_STRING}   ^wp=Mission$
RewriteRule   ^(.*)$ http://domain.org.au/webpage.php?wp=Mackay%20Mission   [R=301,L]

But the result is:

http://domain.org.au/webpage.php?wp=Mission

Am I missing something? I have used this and this as a reference

Community
  • 1
  • 1
Akira Dawson
  • 1,247
  • 4
  • 21
  • 45

1 Answers1

1

I see 2 problems with your first attempt : there is no need for the leading slash in the RewriteRule, and the %20 doesn't work as "%" is a special character. Here what you can try :

# Solution 1 : with a space character in the final URL
RewriteCond %{QUERY_STRING} ^wp=Mission$
RewriteRule ^webpage-mackay\.php$ http://domain.org.au/webpage.php?wp=Mackay\ Mission [R=301,L]

# Solution 2 : with the %20 in the final URL
RewriteCond %{QUERY_STRING} ^wp=Mission$
RewriteRule ^webpage-mackay\.php$ http://domain.org.au/webpage.php?wp=Mackay\%20Mission [R=301,L,NE]
ôkio
  • 1,772
  • 1
  • 15
  • 16