清理嵌套mod_rewrite的声明 [英] Cleaning up nested mod_rewrite statements
问题描述
我清理含有大量的的mod_rewrite
语句的大的.htaccess
文件。
I am cleaning up a large .htaccess
file containing a lot of mod_rewrite
statements.
杂波的最大部分来自陈述捕捉各种事件的
The biggest part of the clutter comes from statements catching various occurrences of
/directory1
/directory1/directory2
/directory1/directory2/directory3
using语句像
using statements like
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)$
RewriteRule .* /front.php?level1=%1&level2=%2&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)/([^/]+)$
RewriteRule .* /front.php?level1=%1&level2=%2&level3=%3&%{QUERY_STRING} [L]
可能有人精通的mod_rewrite给我如何写一个通用的语句指针会赶上 directory1中/ directory2 ...
的任何深度,并出台相应的水平
可变进重写规则?
could somebody versed with mod_rewrite give me a pointer on how to write one universal statement that will catch any depth of directory1/directory2...
and put the appropriate level
variable into the RewriteRule?
推荐答案
而使用以下重写规则
RewriteRule ^(.*)$ front.php/$1 [L]
和访问由PATHINFO文件夹 front.php
:
and access folders by pathinfo in front.php
:
$pathinfo = $_SERVER['PATH_INFO'];
您也可以也使多视图
在Apache和配置使用 front.php
为索引文件,而不是与抓住PATHINFO方式相同。
You can alternatively also enable MultiViews
in Apache and configure it to use front.php
as index file instead and grab pathinfo the same way.
这篇关于清理嵌套mod_rewrite的声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!