Apache:如何在不使用_请求的情况下制定相同的重写规则?
如何在不使用请求的情况下制定相同的重写规则Apache:如何在不使用_请求的情况下制定相同的重写规则?,apache,.htaccess,mod-rewrite,url-rewriting,slash,Apache,.htaccess,Mod Rewrite,Url Rewriting,Slash,如何在不使用请求的情况下制定相同的重写规则 RewriteEngine On # Rewrite multiple slashes with single slash after domain RewriteCond %{THE_REQUEST} ^[A-Z]+\s//+(.*)\sHTTP/[0-9.]+$ [OR] RewriteCond %{THE_REQUEST} ^[A-Z]+\s(.*/)/+\sHTTP/[0-9.]+$ RewriteRule .* http://%{HTTP_H
RewriteEngine On
# Rewrite multiple slashes with single slash after domain
RewriteCond %{THE_REQUEST} ^[A-Z]+\s//+(.*)\sHTTP/[0-9.]+$ [OR]
RewriteCond %{THE_REQUEST} ^[A-Z]+\s(.*/)/+\sHTTP/[0-9.]+$
RewriteRule .* http://%{HTTP_HOST}/%1 [R=301,L,NE]
更新:
.htaccess位置-www.domain.com/url/.htaceess重写操作-www.domain.com//url/id重写为www.domain.com/url/id这个怎么样 重写cond%{REQUEST_URI} ^(.)/(.)重写规则。%1/%2 [R=301,L]
拿走了。(不幸的是,我无法在这里测试它)。似乎没有Apache的解决方案
%{THE_REQUEST}
当.htaccess位于localhost/dir/.htaccess中时,重写规则将不起作用(localhost//dir/将返回相同的结果)。不幸的是,这与URL开头的多个斜杠不匹配,如http://domain.com///file.htm
,因为这些斜杠不包含在%{REQUEST_URI}
..@Floern中-您可以检查,我的规则工作正常,只是我想知道如何使用REQUEST\u URI
而不是the\u REQUEST
。我很好奇-如果它满足您的需要,为什么您不想使用\u REQUEST?@DanTup-Danny Tuppeny-the \u REQUEST
返回非拉丁URL的urlencode,但是我需要返回urldecode。我想,请求
是唯一一个包含多个前面斜杠的变量。所以答案是:不。不要忘记?
查询–您可能不想从查询中删除斜杠。