以下是我使用.htaccess获取三个虚拟子文件夹的代码:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ index.php?url=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)$ index.php?url=$1&sub=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?url=$1&sub=$2&subsub=$3 [L]
问题是:是否可以使其更简单?例如:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?url=$1&sub=$2&subsub=$3 [L]
我知道这不行。我只想弄清楚它是否是添加更多子文件夹的唯一方法。如果我需要,比方说六,(url / sub / sub2 / sub3 / sub4 / sub5 ....等等)?
提前谢谢