我有当前的重写规则:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?page=$1 [L,QSA]
这对于http://www.example.com/something非常有用,但我也希望能够有子页面,即:http://www.example.com/something/something。我希望它采取以下形式:
index.php?page=$1&subpage=$2
或
index.php?page=something&subpage=$1
有人可以指出我正确的方向吗?
答案 0 :(得分:5)
放手一搏:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?page=$1&subpage=$2 [L,QSA]
你也可以在一个规则中制作这两个规则:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?:([^/]+)|)(?:/([^/]+)|)/?$ index.php?page=$1&subpage=$2 [L,QSA]