mod_rewrite 帮助
由于某种未知的原因,我的重写规则没有触发。 你能提供建议吗?
/extranet/.htaccess
(1)/extranet/stable/
/extranet/dev/
/extranet/dev/.htaccess< /code> (2)
第一个 .htaccess 将所有流量重定向到 stable 文件夹,但专门指向 dev 文件夹的 URL 除外。 效果很好。
在 dev 文件夹中,第二个 .htaccess 应该将 /extranet/dev/foo/
重写为 /extranet/dev/index.php?app=foo
。
这让我失望了。
IndexIgnore *
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#--------------------------------------------
# FRIENDLY URLs
#--------------------------------------------
# if the following conditions are met, SKIP the rewriteRules.
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC,OR]
RewriteCond %{REQUEST_URI} ^/(|_css/|_js/|_img/) [NC]
RewriteRule . - [L]
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?app=$1 [NC,QSA,L]
For some unknown reason, my rewrite rule does not fire. Can you advise ?
/extranet/.htaccess
(1)/extranet/stable/
/extranet/dev/
/extranet/dev/.htaccess
(2)
The first .htaccess redirects all traffic to the stable folder, except for URLs specifically pointed at the dev folder. That works fine.
Inside the dev folder, the second .htaccess is supposed to rewrite /extranet/dev/foo/
to /extranet/dev/index.php?app=foo
.
And that fails me.
IndexIgnore *
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#--------------------------------------------
# FRIENDLY URLs
#--------------------------------------------
# if the following conditions are met, SKIP the rewriteRules.
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC,OR]
RewriteCond %{REQUEST_URI} ^/(|_css/|_js/|_img/) [NC]
RewriteRule . - [L]
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?app=$1 [NC,QSA,L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
^/(|_css/|_js/|_img/)
的第一个交替选项是^/
并且针对REQUEST_URI
测试的结果始终为 true 。The first alternation option of
^/(|_css/|_js/|_img/)
is^/
and that tested againstREQUEST_URI
is always true.