给大家一点帮助吧。
我目前所拥有的(基于我用于不同类型的URL的一些代码)。
我希望第一个URL重定向到第二个,之后不包含任何查询字符串
到目前为止,这就是我要做的。
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]发布于 2011-09-29 17:39:21
以下是规则(将重定向1个URL):
RewriteCond %{QUERY_STRING} ^id=whatever
RewriteRule ^page\.php$ http://%{HTTP_HOST}/how/somehow? [R=301,L]%{HTTP_HOST} --这将重定向到与请求的URL相同的域。如果域名必须不同,请将其替换为确切的域名。?将删除现有的查询字符串。发布于 2011-09-29 17:38:36
哈哈!
试一试:
#check mod_rewrite is enabled
<IfModule mod_rewrite.c>
#enable mod rewrite
RewriteEngine On
#set working directory
RewriteBase /
#force trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [R=301,L]
#bootstrap index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^page.php\?id=(.*)$ http://www.willans.com/page.php/$1 [R=310,L]
#end mod rewrite check
</IfModule>我已经有一段时间没有做过网络开发了,但这至少应该是在正确的方向上推动;)
https://stackoverflow.com/questions/7594697
复制相似问题