请帮忙,有些网站会动态添加动态查询字符串到我的主页。.htaccess将基于index.php页面的非现有页面重定向到通配符后面的内容到index.php
例如我的主页是www.mysite.com/index.php并链接到许多环节是这样的:
www.mysite.com/index.php?a=something-something-something
www.mysite.com/index.php?a=something-other
www.mysite.com/index.php?a=some-other-thing
而且这些链接打开我的网站,网页内容是相同的为每一页,就像我的原始www.mysite.com/index.php
有几百指向我的网站的链接。因此,如何我也可以把这样的:
www.mysite.com/index.php?a=something-something-something
www.mysite.com/index.php?a=something-other
www.mysite.com/index.php?a=some-other-thing
...
到
www.mysite.com/index.php
或者只是www.mysite.com/
这是我试图在我的.htaccess文件至今
RedirectMatch 302 ^index.php?a= http://www.www.example-ste.com/
RewriteRule ^/index.php?a=(.*) http://www.example-ste.com/
但仍然页面在现场开放。
另一个类似的问题。
如何重定向与“pagewanted =所有?”在同一页但指出,结束页面“pagewanted =一切?”
比如我需要重定向页面:
www.mysite.com/something-something/something.html?pagewanted=all
到
www.mysite.com/something-something/something.html
你好。
我刚注意到一些东西。我需要URL重定向规则,这将重定向页面,如:
www.mysite.com/index.php?a=something-something-something
www.mysite.com/index.php?a=something-other
www.mysite.com/index.php?a=some-other-thing
到网站,根的主页。而你给了我这个代码:
RewriteEngine On
RewriteBase/
#if the query string has an a parameter
RewriteCond %{QUERY_STRING} (^|&)a= [NC]
#Redirect and remove query string parameters
RewriteRule .* http://www.mysite.com/? [R=301,L]
而且我必须说,它工作得很好,但它确实是,但我只注意到它在某种程度上阻止或重新定向含?a=
例如对我有这样的联系一些临时网页所有链接:
i.php?a=something-something-something
那么,你可以采用代码只是基于索引的页面。PHP这样的:
www.mysite.com/index.php?a=something-something-something
,而不是与链接:
i.php?a=something-something-something
如果我是正确的它适用于所有链接以“a=
”,但我只需要为“index.php?a=
”
有没有人有任何解决方案呢? – 2011-12-20 18:56:45