使用 mod_rewrite 来更改带冒号的页面
通过检查我的错误日志,我发现我有一个指向 http://site.com/javascript:;;
的链接,
我想使用 mod_rewrite 规则将用户重定向到主页。 我尝试了以下所有方法:
RewriteCond %{THE_REQUEST} /javascript: [NC,OR]
RewriteCond %{THE_REQUEST} /javascript%3a [NC,OR]
RewriteCond %{THE_REQUEST} /javascript\%3a [NC,OR]
RewriteCond %{THE_REQUEST} /javascript%%3a [NC,OR]
RewriteCond %{REQUEST_URI} /javascript: [NC,OR]
RewriteCond %{REQUEST_URI} /javascript%3a [NC,OR]
RewriteCond %{REQUEST_URI} /javascript\%3a [NC,OR]
RewriteCond %{REQUEST_URI} /javascript%%3a [NC]
RewriteRule ^.*$ http://%{HTTP_HOST}/ [L,R=301]
但这些情况都没有感染结肠。
谢谢
By checking my error logs, I found that i have a link to http://site.com/javascript:;;
I want to use a mod_rewrite rule to redirect the user to the homepage.
I tried all of the following:
RewriteCond %{THE_REQUEST} /javascript: [NC,OR]
RewriteCond %{THE_REQUEST} /javascript%3a [NC,OR]
RewriteCond %{THE_REQUEST} /javascript\%3a [NC,OR]
RewriteCond %{THE_REQUEST} /javascript%%3a [NC,OR]
RewriteCond %{REQUEST_URI} /javascript: [NC,OR]
RewriteCond %{REQUEST_URI} /javascript%3a [NC,OR]
RewriteCond %{REQUEST_URI} /javascript\%3a [NC,OR]
RewriteCond %{REQUEST_URI} /javascript%%3a [NC]
RewriteRule ^.*$ http://%{HTTP_HOST}/ [L,R=301]
But none of these conditions catch the colon.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不需要
RewriteCond
。您可以像这样简化:RewriteRule javascript:;; http://%{HTTP_HOST}/? [NC,L,R = 301]
No need for the
RewriteCond
. You can simplify this like so:RewriteRule javascript:;; http://%{HTTP_HOST}/? [NC,L,R=301]
好吧,对不起。看来我的本地服务器配置有一些错误。
在我的生产服务器上,这有效:
pppfffff。我花了一些时间。 :)
OK, i'm sorry. it seems that my local server has some misconfigurations.
on my production server, this works:
pppfffff. took me some time. :)