使用正则表达式阻止.htaccess中的URL

如果它们匹配htaccess文件中的正则表达式,我想阻止几个URL。</ p>

这些是我想在htaccess中阻止的网址。 </ p>

网址格式中包含以下内容的任何内容:</ p>


  • mp4:</ li>
  • wp- 内容</ li>
  • phpMyAdmin </ li>
    </ ul>

    所有不区分大小写的请注意,“mp4:”必须包含与表达式匹配的冒号。< / p>

    我该如何做到这一点?</ p>

    谢谢! </ p>
    </ div>

展开原文

原文

I would like to block a couple of URLs if they match a regular expression in the htaccess file.

These are the URLs I want to block in htaccess.

Anything that contains the following in the URL pattern:

  • mp4:
  • wp-content
  • phpMyAdmin

All case insensitive, please note that the "mp4:" must include the colon to match the expression.

How can I accomplish this?

Thanks!

drebew5059
drebew5059 httpd.apache.org/docs/current/mod/core.html#filesmatch
大约 7 年之前 回复

2个回答



这应该有效:</ p>

  RewriteEngine On 
RewriteCond%{THE_REQUEST} ^。 (wp-content)|(phpMyAdmin)|(mp4:)。 [NC]
RewriteRule ^(。*)$ - [F,L]
</ code> </ pre>

然后将为包含此类字符串的网址显示“禁止”消息。 例如:</ p>


您无权访问此服务器上的/ foomp4:bar /。</ p>
</ blockquote>
</ div >

展开原文

原文

This should work:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^.*(wp-content)|(phpMyAdmin)|(mp4:).* [NC]
RewriteRule ^(.*)$ - [F,L]

Then a Forbidden message will be displayed for urls containing such string. e.g.:

You don't have permission to access /foomp4:bar/ on this server.



我希望这就是你要找的,例如</ p>

RedirectMatch users /(.+ ) http://www.exapmles.com/profiles/ $ 1 [R = 301,L] </ p>

可在此处找到更多信息
https ://superuser.com/questions/155139/htaccess-301-redirect-with-regular-expressions </ p>

在您的情况下,您应该添加多行! :)</ p>
</ div>

展开原文

原文

I hope this is what you are looking for, example

RedirectMatch users/(.+) http://www.exapmles.com/profiles/$1 [R=301,L]

more information can be found here https://superuser.com/questions/155139/htaccess-301-redirect-with-regular-expressions

In your case you should add multiple lines! :)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问