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]