HTACCESS多个子文件夹 - 最佳实践?

时间:2016-03-26 04:23:09

标签: .htaccess

以下是我使用.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 ....等等)?

提前谢谢

0 个答案:

没有答案