[英].htaccess rewrite for sub pages
I have the current rewrite rule: 我有当前的重写规则:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?page=$1 [L,QSA]
This works wonderfully for http://www.example.com/something but I would also like to be able to have sub pages, ie: http://www.example.com/something/something . 这对于http://www.example.com/something来说效果很好,但我也希望能够拥有子页面,即: http : //www.example.com/something/something 。 I would like it to take the form of: 我希望它采取以下形式:
index.php?page=$1&subpage=$2
or 要么
index.php?page=something&subpage=$1
Can someone please point me in the right direction? 有人可以指出正确的方向吗?
Give this a go: 试试看:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?page=$1&subpage=$2 [L,QSA]
You can also make both in one rule like this: 您也可以按照以下一条规则同时做这两项:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?:([^/]+)|)(?:/([^/]+)|)/?$ index.php?page=$1&subpage=$2 [L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.