我在编写规则时遇到了麻烦,它会将http:// localhost / hello:world这样的地址重写为http://localhost/hello/world.html
我在httpd.conf中的RewriteRule如下所示:
<Directory "D:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all RewriteEngine On RewriteBase / RewriteRule ^hello:world$ /hello/world.html [L,QSA] #Doesn't work RewriteRule ^hello_world$ /hello/world.html [L,QSA] #Works great! </Directory>
当我尝试http:// localhost / hello:world时 ,我收到一个403 Forbidden页面。
特别要注意的是,这个规则
RewriteRule ^hello_world$ /hello/world.html [L,QSA]
通过http:// localhost / hello_world工作得很好。
我在Windows Server 2008下使用Apache2.2。
我将如何重写规则来匹配冒号?
当有疑问时总是逃脱
RewriteRule ^hello\:world$ /hello/world.html [L,QSA]