ci:使用index.php的google索引地址,但网站中没有与index.php的链接

时间:2014-07-25 18:02:21

标签: php .htaccess codeigniter seo codeigniter-url

我有一个由codeigniter编写的网站,我已经通过htaccess从地址中删除了index.php

RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

我的base_url()也将输出没有index.php的站点域 所以我在网站上的所有链接都没有index.php即:

www.site.com/news/add
www.site.com/faq
www.site.com/offers/archive 

所以这是问题所在: 我注意到谷歌已经使用索引php从我的网站索引了很多地址 例如我在我的网站上有这个地址:

www.site.com/offer/map

但谷歌只有

www.shadyab.com/index.php/offer/map

索引不是第一个!

谷歌在哪里获得这些链接?

这是我的routes.php

$route['default_controller'] = 'index';
$route['404_override'] = '';
$route['cp'] = 'cp/admin';
$route['404.php']      = "404.php";
$route["page/(:any)"]   = "page/title/$1";
$route["offers/(:any)"] = "offer/get/$1";
$route["category/(:any)"] = "offer/open/0/$1";
$route["rss"] = "news/rssOffers";
$route['sitemap\.xml'] = "offer/sitemap";

我的htaccess

 AddType application/x-httpd-php53 php53 php


<IfModule mod_rewrite.c>

RewriteEngine on



#forcing www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# redirecting addresses with index.php to address without it
# (i've added this just yesterday it's not related to my problem )
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php(/[^\s\?]+)? [NC]
RewriteRule ^ %1/ [L,R]

#adding inddex.php internally 
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 



</IfModule>


order allow,deny
allow from all

1 个答案:

答案 0 :(得分:0)

您的网站正在重定向index.php,但它正在发送302重定向,即temporary redirect。您要做的是使用301 Moved Permanently

使用301,Google会通知旧网址不再有效,并使用新网址更新其索引。

Change 302

将此规则添加到.htaccess

RewriteRule ^index.php/(.*)$ /$1 [R=301,L]