2014-03-13 29 views
0

这是我的htaccess代码:htaccess的重写 “” 用 “ - ”

RewriteEngine On 

RewriteRule ^contact$ contact.php [QSA,L] 
RewriteRule ^error$ error.php [QSA,L] 

RewriteRule ^([^/.]+)/?$ game.php?title=$1 [L,QSA] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule . /error [L,R=301] 

如何能使其例如工作:

localhost/Test1%20Test2 or localhost/Test1 Test2

一起工作

localhost/test1-test2 

回答

0

有这个规则s你的非常第一个规则

RewriteRule "^([^ ]*) +([^ ]* .*)$" /$1-$2 [L] 
RewriteRule "^([^ ]*) ([^ ]*)$" /$1-$2 [L,R=301] 
+0

它没有工作 –

+0

你能提供详细资料吗?你试过什么网址来测试它,以及你得到了什么? – anubhava