我为小型项目编写了一个小型框架(PHP),除了定义的路径外,它应该重定向到index.php?path=$1。有了 END 标志,这就不成问题了。但自 Apache 2.3 以来 END 标志仍然存在,并且该脚本也应该可以在 apache 2.2 服务器上运行。
有谁知道我如何在没有 END 标志的情况下实现这一点?
RewriteEngine on
# Define static redicts
RewriteRule ^image/(.+)$ public/image/$1 [END,QSA]
RewriteRule ^css/(.+)$ public/css/$1 [END,QSA]
RewriteRule ^js/(.+)$ public/js/$1 [END,QSA]
RewriteRule ^lib/js/core/(.+)$ core/lib/js/$1 [END,QSA]
RewriteRule ^lib/js/(.+)$ public/lib/js/$1 [END,QSA]
RewriteRule ^cache/(.+)$ public/cache/$1 [END,QSA]
RewriteRule ^download/(.+)$ public/download/$1 [END,QSA]
# Define custom redicts
RewriteRule ^page/([0-9]+)$ index.php?path=index.php&page=$1 [END,QSA]
# Define all other redicts
RewriteRule ^(.+)$ index.php?path=$1 [L,QSA]
由于您的所有规则都以END
标志,您或多或少想要完全阻止重写引擎的任何循环。不使用来完成同样的事情END
标志,将它们全部替换为L
标记并添加直通规则开始:
RewriteEngine on
# pass-through if another rewrite rule has been applied already
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
# Define static redicts
RewriteRule ^image/(.+)$ public/image/$1 [L,QSA]
RewriteRule ^css/(.+)$ public/css/$1 [L,QSA]
RewriteRule ^js/(.+)$ public/js/$1 [L,QSA]
RewriteRule ^lib/js/core/(.+)$ core/lib/js/$1 [L,QSA]
RewriteRule ^lib/js/(.+)$ public/lib/js/$1 [L,QSA]
RewriteRule ^cache/(.+)$ public/cache/$1 [L,QSA]
RewriteRule ^download/(.+)$ public/download/$1 [L,QSA]
# Define custom redicts
RewriteRule ^page/([0-9]+)$ index.php?path=index.php&page=$1 [L,QSA]
# Define all other redicts
RewriteRule ^(.+)$ index.php?path=$1 [L,QSA]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)