网址:http://example.com/good_game/osmp/
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_game
或http://example.com/good_game/
我需要
Array ( [service] => good_game)
并返回404未找到
答案 0 :(得分: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