htaccess的从URL中删除的index.php [英] htaccess remove index.php from url

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

问题描述

我有一个问题,即谷歌已收录一些页面有错误的URL。

I have a problem whereby google has indexed some pages with the wrong url.

他们索引的网址是:

http://www.example.com/index.php/section1/section2

我需要它重定向到:

I need it to redirect to:

http://www.example.com/section1/section2

的.htaccess是不是我的专长,所以任何帮助将非常AP preciated。

.htaccess isn't my forte, so any help would be much appreciated.

在此先感谢。

推荐答案

这是基本的规则来隐藏的index.php 从URL。把这个在你的根的.htaccess 文件。

This is the basic rule to hide index.php from the URL. Put this in your root .htaccess file.

的mod_rewrite 必须用PHP启用,这将适用于比5.2.6更高版本的PHP。

mod_rewrite must be enabled with PHP and this will work for the PHP version higher than 5.2.6.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

有关PHP版本低于5.2.6试试这个:

For PHP version less than 5.2.6 try this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L] 

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

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