[英]Apache .htaccess rewrite rule removing double slash unintentionally
我有一个简单的重写规则,它传递一个简单的字符串(attr ' mode
')和一个 url (attr target_url
),格式为: http : //dummypage.com/
RewriteRule ^test/([^/.]*)/(.*)$ /index.php?mode=$1&target_url=$2
转换
mydomain.com/test/stringparam/http://dummypage.com/
到
mydomain.com/index.php?mode=stringparam&target_url=http:/dummypage.com/
注意它把http://dummypage.com/改成了http://dummypage.com/ ,为什么要去掉双斜线?
您无法使用RewriteRule
匹配此类 URI。 使用THE_REQUEST
变量来匹配它。 THE_REQUEST
变量代表 Apache 从您的浏览器收到的原始请求。
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+test/([^/]+)/([^\s]*)\s [NC]
RewriteRule ^ /index.php?mode=%1&target_url=%2 [L,QSA,NE]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.