这真让我烦恼,我已经按照了一些教程但是无法到达任何地方。我正在尝试从以下位置进行301重定向:
/webpage-mackay.php?wp=Mission
为:
http://domain.org.au/webpage.php?wp=Mackay%20Mission
我试图这样写:
RewriteCond %{QUERY_STRING} ^wp=Mission$
RewriteRule ^/webpage-mackay\.php$ http://domain.org.au/webpage.php?wp=Mackay%20Mission [R=301,L]
和
RewriteCond %{REQUEST_URI} ^/webpage-mackay.php$
RewriteCond %{QUERY_STRING} ^wp=Mission$
RewriteRule ^(.*)$ http://domain.org.au/webpage.php?wp=Mackay%20Mission [R=301,L]
但结果是:
http://domain.org.au/webpage.php?wp=Mission
答案 0 :(得分:1)
我在第一次尝试时看到2个问题:RewriteRule中不需要前导斜杠,而%20不起作用,因为“%”是一个特殊字符。 在这里你可以尝试:
# 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]