url重写问题
在我的 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加
RewriteCond
:当您转到
/cms
时,Apache 可能会对/cms/
执行 301,因此您的重写规则将匹配。这将避免匹配/cms/
。Add a
RewriteCond
:When you go to
/cms
, Apache probably does a 301 to/cms/
, therefore your rewrite rule would match. This will avoid matching/cms/
.添加:
RewriteRule ^(.*)/?$ $1/index.php [L]
Add:
RewriteRule ^(.*)/?$ $1/index.php [L]