mod_rewrite 帮助

发布于 2024-08-01 17:26:04 字数 973 浏览 4 评论 0原文

由于某种未知的原因,我的重写规则没有触发。 你能提供建议吗?

  • /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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灯角 2024-08-08 17:26:04

^/(|_css/|_js/|_img/) 的第一个交替选项是 ^/ 并且针对 REQUEST_URI 测试的结果始终为 true 。

The first alternation option of ^/(|_css/|_js/|_img/) is ^/ and that tested against REQUEST_URI is always true.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文