通过 htaccess 从 url 中删除 index.php [英] Remove index.php from url by htaccess

查看:32
本文介绍了通过 htaccess 从 url 中删除 index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Im developing a php frame work and I am new to .htaccess rules. So I need to redirect url using .htaccess. Url is

http://localhost/rinocabs/index.php?/Galary/Image/

应该转换成这个

http://localhost/rinocabs/Galary/Image/

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

in .htaccess file I include these rules

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

但它不起作用.请帮忙.

but its not working. Please Help.

推荐答案

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/

代替

localhost/rinocabs/index.php?/Galary/Image/

localhost/rinocabs/index.php?/Galary/Image/

这篇关于通过 htaccess 从 url 中删除 index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆