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

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

问题描述

即时通讯开发一个PHP框架的工作,我是新来的.htaccess规则。所以,我需要重定向 URL使用的.htaccess。网址为

 的http://localhost/rinocabs/index.php / Galary /图像/
 

应转换到这一

 的http://本地主机/ rinocabs / Galary /图像/
 

在.htaccess文件我有这些规则

 选项+了FollowSymLinks
RewriteEngine叙述上
的RewriteCond%{HTTP_HOST} ^本地主机/ rinocabs /的index.php?/ Galary /图像/ [NC]
(。*)重写规则^ $的http://本地主机/ rinocabs / Galary /图片/ $ 1 [R = 301,NC]
 

但它不工作。请帮助。

解决方案

 选项+了FollowSymLinks -MultiViews
#开启mod_rewrite的上
RewriteEngine叙述上
的RewriteBase /

的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php?$ 1 [L,QSA]

的RewriteCond%{THE_REQUEST} ^ [AZ] {3,} \ S(。*)/指数\ .PHP [NC]
重写规则^%1 [R = 301,L]
 

使用

  

本地主机/ rinocabs / index.php文件/ Galary /图片/

而不是

  

本地主机/ rinocabs /的index.php?/ Galary /图片/

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/

should be converted to this

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

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]

use this

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

instead of

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

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

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