.htaccess - 获取 "mywebsite.org/"解析为 "mywebsite.org/index.php"

标签 .htaccess redirect seo indexing http-status-code-301

在我的工作中,我们有各种网页,我的老板认为,这些网页的排名低于应有的排名,因为“mywebsite.org/category/”在搜索引擎中看起来与“mywebsite.org/category/”不同index.php"确实如此,即使它们显示的是同一个文件。我认为这种方式行不通,但他深信不疑。也许我错了。我有两个问题:

  1. 如何让它在所有子类别的地址栏中显示“index.php”?
  2. 这真的是 pagerank 的运作方式吗?

最佳答案

  1. 除了更改所有链接之外,更简单的解决方案是使用重写规则。确保它是永久重定向,否则 Google 将继续使用旧链接(没有 index.php)。如何执行此操作完全取决于您的 Web 服务器,但对于 Apache HTTPd,它看起来类似于下面给出的示例。
  2. 是的。或者我听说过。很少有人知道。但是Google mentions this guideline (如“保持一致”)。确保检查所有 Google's Webmaster guidelines .

重写规则的 Apache 配置:

# in the generic config
LoadModule rewrite_module modules/mod_rewrite.so

# in your virutal host
RewriteEngine On

# redirect everything that ends in a slash to the same, but with index.php added
RewriteRule ^(.*)/$ $1/index.php [R=301,L]

# or the other way around, as suggested
# RewriteRule ^(.*)/index.php$ $1/ [R=301,L]

关于.htaccess - 获取 "mywebsite.org/"解析为 "mywebsite.org/index.php",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1308485/

相关文章:

redirect - 登录到 Azure AD 而不重定向 Microsoftpage

optimization - 为重音字符构建 SEO 友好的 URL

php - .htaccess 重写 GET 变量

php - 使用 mod_rewrite 格式化 URL 参数

javascript - URL重写: Show all files of certain directories at root of site

apache - htaccess的绝对路径

php - htaccess 页面根据参数条件重定向

http - 将客户端路由到 node.js 中的外部站点?

seo - 谁能告诉我为什么我的网站描述不会显示在搜索结果中?

seo - 用查询字符串分页不好吗?