【发布时间】: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