通过我们的脚本生成的某些URL。我需要通过htaccess的修剪所有这些; 我对他们有几百个,因此所有?xxx将必须清洗。
Some urls are generated via our script. I need to trim all these via htaccess; I have a few hundred of them, so all ?xxx have to be cleaned.
例如:
domain.com/page.html?word=gclid=4nwseuoSg
到
domain.com/page.html
或任何开始?,α-并且不需要的其余部分。
or anything starting with ?, the ? and the rest is not needed.
我试过重写规则^ $ / [R = 301,L] ,但没有工作?(*):(
I tried RewriteRule ^?(.*)$ / [R=301,L] but did not work :(
我有什么用,而不是 ?(。*)
不包含查询字符串的路径。使用的RewriteCond匹配任何没有空的查询字符串。
the path doesn't contain the querystring. Use RewriteCond to match any none-empty querystring.
RewriteCond %{QUERY_STRING} !^$
RewriteRule .html$ $0 [R=301,L]
我还添加了一个条件,即URL已结束在的.html
以防万一你要添加在未来的一段PHP脚本。
I also added a condition that the url has to end in .html
just in case you want to add some php script in the future.
上一篇:为什么要重写规则在.htaccess不会有效果吗?重写、规则、效果、htaccess
下一篇:的RewriteCond%{REQUEST_URI}:如何停止,如果REQUEST_URI含有P =约或P =接触?RewriteCond、REQUEST_URI