帮助老乡了一点,所以人。
我目前所面对的(基于一些code我用不同类型的URL)。
我要第一个URL重定向到第二,与事后没有包括查询字符串
这是我迄今。
重写规则^(page.php?ID = missionstatement +)/ $ http://example.com/why/mission-statement [R = 301,L]
重写规则^(page.php?ID = OFSTED +)/ $ http://example.com/how/ofsted-report [R = 301,L]
重写规则^(page.php?ID = governingbody +)/ $ http://example.com/governors [R = 301,L]
解决方案
下面是规则(将重定向1网址):
的RewriteCond%{QUERY_STRING} ^ n =什么
重写规则^页 .PHP $ HTTP://%{HTTP_HOST} /如何/不知何故? [R = 301,L]
该规则旨在放置在.htaccess在网站根目录。如果放在其他地方的一些小的调整可能是必需的。
我已经使用%{HTTP_HOST}
- 这将重定向到同一个域中请求的URL。如果域名已经是不同的,通过精确的域名替换它。
在?
在新的URL年底将摆脱现有的查询字符串。
A bit of help fellow SO people.
What I have at the moment (based on some code I used for a different type of URL).
I want the first URL to redirect to the second, with no query string included afterwards
This is what I have to so far.
RewriteRule ^(page.php?id=missionstatement+)/?$ http://example.com/why/mission-statement [R=301,L]
RewriteRule ^(page.php?id=ofsted+)/?$ http://example.com/how/ofsted-report [R=301,L]
RewriteRule ^(page.php?id=governingbody+)/?$ http://example.com/governors [R=301,L]
解决方案
Here is the rule (will redirect 1 URL):
RewriteCond %{QUERY_STRING} ^id=whatever
RewriteRule ^page.php$ http://%{HTTP_HOST}/how/somehow? [R=301,L]
This rule intended to be placed in .htaccess in website root folder. If placed elsewhere some small tweaking may be required.
I have used %{HTTP_HOST}
-- this will redirect to the same domain as requested URL. If domain name has to be different, replace it by exact domain name.
The ?
at the end of new URL will get rid of existing query string.