【问题标题】:Remove index.php from google search URL从谷歌搜索 URL 中删除 index.php
【发布时间】:2015-07-28 12:40:11
【问题描述】:

我希望能够从 google 的搜索列表中删除 index.php URL,您可能会在搜索网站标题时看到这一点(之间有或没有空格)。在我的第二页上,它显示了我的网站,但 URL 末尾有 index.php!

我已经编辑了 httpd.conf 以从我的 URL 末尾删除 index.php,您可以在下面看到我的内容:

<VirtualHost *:80>
    ServerName joemethven.com
    DocumentRoot /var/www/html/joemethven/
</VirtualHost>

Options -MultiViews

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^([^\.]+)$ $1.html [NC,L]

当网站加载 joemethven.com 时,为什么 Google 会选择 index.php?有什么办法可以防止这种情况发生吗?!

感谢阅读,希望有人能帮忙! :)

更新:我刚刚在我的网站文件夹中快速添加了一个 .htaccess,其中包含以下信息:

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteCond %{REQUEST_FILENAME}\.html -f 
RewriteRule ^(.*)$ $1.html

RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php

我不知道这是否会做出任何改变,但是我的其他运行网站的服务器没有这个问题,他们的 .htaccess 文件中有这些信息。

【问题讨论】:

    标签: linux apache .htaccess httpd.conf


    【解决方案1】:

    修复比我想象的要容易,只需转到 Google 的网站管理员工具,我使用“提交到索引”功能并设置我的首选 URL 而不使用 index.php,它对我来说已经改变了!

    【讨论】:

      猜你喜欢
      • 2018-10-21
      • 2015-03-17
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-14
      • 2014-10-28
      相关资源
      最近更新 更多