我的网站是mywebsite.com/this.php?That=Blah+Blah
我的重写规则是
RewriteEngine on
RewriteRule ^That/([A-Za-z0-9-+]+)/?$ this.php?That=$1 [NC]
RewriteEngine on
RewriteRule ^([A-Za-z0-9-+]+)/?$That/$1 [NC]
当我输入mywebsite.com/Blah+Blah时它工作正常。
当我输入mywebsite.com/Blah-Blah以获得相同的结果时,如何使用 - 符号更改+符号?
答案 0 :(得分:1)
您可以为hyphen to +
转化添加新规则:
RewriteEngine on
RewriteRule ^([^-]*)-(.*)$ /$1\+$2 [L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w+]+)/?$ /this.php?That=$1 [L,QSA,NE]