linux - 从 google 搜索 URL 中删除 index.php

标签 linux apache .htaccess httpd.conf

我希望能够删除 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 文件中包含此信息。

最佳答案

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

关于linux - 从 google 搜索 URL 中删除 index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30278981/

相关文章:

mysql - 在 linux 上通过命令行访问 XAMPP mysql

apache2 在重写之前给出 404

Wordpress 文件和目录权限 : cannot open or save with my local user

apache - 无操作 Apache mod_rewrite 规则

c++ - 减少所需的 libc 版本

linux mint opencv 2.4.7 make 失败 - filtering.cpp 对 opencl_kernels.hpp 的引用,74% 后未找到

linux - 如何退出没有任何错误运行的 watch ?

linux - 关于库相对路径以及如何重用属性字符串的 qbs 问题

php - .htaccess 使文件夹充当根目录?

regex - 使用 htaccess 将 Paypal 回调重新格式化为自定义 URL 格式