url重写问题

发布于 2024-09-12 16:40:39 字数 471 浏览 0 评论 0原文

在我的 .htaccess 文件中,我有以下内容

Options -Indexes
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteRule ^(.*)/(.*)$  index.php?lang=$1&id=$2 [L]

,因此当我编写 http://mydomain.com/am/home 时,它​​将被重定向到 http:// mydomain.com?lang=am&id=home


但我有一个 cms 文件夹,我需要转到

http://mydomain.com/cms/index。 php 当写入

http://mydomain.com/cms 但它没有发生。

我能做些什么?

谢谢

in my .htaccess file i have the following

Options -Indexes
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteRule ^(.*)/(.*)$  index.php?lang=$1&id=$2 [L]

so when i wrote http://mydomain.com/am/home it will be redirected to http://mydomain.com?lang=am&id=home


but i have a cms folder, and i need to go to

http://mydomain.com/cms/index.php when wrote

http://mydomain.com/cms but it doesn't happen.

what can i do?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

非要怀念 2024-09-19 16:40:39

添加 RewriteCond

RewriteCond $1 !=cms
RewriteRule ^(.*)/(.*)$  index.php?lang=$1&id=$2 [B,L]

当您转到 /cms 时,Apache 可能会对 /cms/ 执行 301,因此您的重写规则将匹配。这将避免匹配 /cms/

Add a RewriteCond:

RewriteCond $1 !=cms
RewriteRule ^(.*)/(.*)$  index.php?lang=$1&id=$2 [B,L]

When you go to /cms, Apache probably does a 301 to /cms/, therefore your rewrite rule would match. This will avoid matching /cms/.

早乙女 2024-09-19 16:40:39

添加:

RewriteRule ^(.*)/?$ $1/index.php [L]

Add:

RewriteRule ^(.*)/?$ $1/index.php [L]

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