微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

通过htaccess从url中删除index.php

我正在开发一个PHP框架工作,我是.htaccess规则的新手.所以我需要重定向
网址使用.htaccess.网址是

http://localhost/rinocabs/index.PHP?/galary/Image/

应该转换成这个

http://localhost/rinocabs/galary/Image/

在.htaccess文件中我包含这些规则

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^localhost/rinocabs/index.PHP?/galary/Image/ [nc]
rewriterule ^(.*)$http://localhost/rinocabs/galary/Image/$1 [r=301,nc]

但它不起作用.请帮忙.

解决方法:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$index.PHP?$1 [L,QSA]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.PHP [NC]
RewriteRule ^ %1 [R=301,L]

用这个

localhost/rinocabs/index.PHP/galary/Image/

代替

localhost/rinocabs/index.PHP?/galary/Image/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐