我写一个重定向到匹配的淅沥/消息的任何URL / *在这里。
I am writing a redirect to match any url of the patter /message/* here.
RewriteRule ^/message/(.+)$ http://abet.in/message/$1 [NC,R=301,L]
现在我想通过禁止在一些URL字符串模式进行修改。
RewriteCond to check /message/index.html in the url.
1. Check if the request url contains /message/index.html.
2. If the condition is not met then do a redirect.
我尝试以下方法。但我不知道他们是否是正确与否。
I tried the following methods. But I am not sure whether they are correct or not.
RewriteCond %{THE_REQUEST} !^/message/index
RewriteCond %{REQUEST_URI} !^/message/index [NC]
能否有人告诉如何做到这一点。
Could some one tell how to do this.
%{THE_REQUEST}
包含一个字符串,看起来像这样为一个普通页面请求:
%{THE_REQUEST}
contains a string that looks like this for a regular page request:
GET /message/index.html HTTP/1.1
和%{REQUEST_URI}
是这样的:
/message/index.html
所以,你的第二个选项是正确的差不多。你并不需要一个 /
在模式的开始的的规则集。
此外,这两个规则将prevent启动的所有请求 /消息/指数
被重定向):
Additionally, these two rules will prevent all requests that start /message/index
from being redirected):
RewriteCond %{REQUEST_URI} !^/message/index [NC]
RewriteRule ^message/(.+)$ http://abet.in/message/$1 [NC,R=301,L]
如果您只想prevent /message/index.html
,而不是 /message/index.php
或 /消息/指数的出头,其他
然后执行:
If you only want to prevent /message/index.html
and not /message/index.php
or /message/index-of-something-else
then do:
RewriteCond %{REQUEST_URI} !^/message/index.html [NC]
RewriteRule ^message/(.+)$ http://abet.in/message/$1 [NC,R=301,L]