2013-08-28 62 views
0

網址:http://example.com/good_game/osmp/mod_rewrite的URL與1或2 PARAMS

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/([^/]+)/?$ /?service=$1&terminal=$2 [L,QSA] 

我收到

Array ([service] => good_game [terminal] => osmp) 

這是確定的,但

網址:http://example.com/good_gamehttp://example.com/good_game/

我需要

Array ([service] => good_game) 

,並返回404未找到

回答

1

這應該兩個工作:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]*|)/?([^/]*|)/?$ /?service=$1&terminal=$2 [L,QSA] 

將匹配:

http://example.com/good_game/osmp/ 
http://example.com/good_game/osmp 
http://example.com/good_game/ 
http://example.com/good_game