1

我有一个简单的重写规则,它传递一个简单的字符串(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/,为什么要删除双斜杠?

4

1 回答 1

3

您无法使用RewriteRule. 使用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]
于 2013-10-09T16:06:46.600 回答