【发布时间】:2014-02-04 17:58:21
【问题描述】:
我将我的网站切换到 wordpress,但现在 url 链接以斜杠(/)而不是 .html 结尾,我不想丢失我的谷歌索引,所以在到处乱撞之后,我终于找到了解决方案.我创建了 .htaccess 规则,该规则将适用于每个页面。
我刚刚使用以下代码更新了根目录下的 .htaccess 文件:
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule ^(.*)\/$ $1.html [R]
RewriteRule ^(.*).html$ index.php/$1 [L]
现在任何像这样的 URL:/features/cart/ 都会自动转发到 /features/cart.html 一切正常,但现在我在那些已经有 .html 扩展名的页面上收到 404 错误。 请尽快提出建议,因为我正在失去我的索引和关键字排名。
下面是.htaccess文件的实际代码:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}/index.php !-f
# Rewrite rule for appending .html
RewriteRule ^(.*)\/$ $1.html [R]
RewriteRule ^(.*).html$ index.php/$1 [L]
redirect 301 /about_us.html /about.html
redirect 301 /about/ /about.html
</IfModule>
# END WordPress
网站名称:dailydealbuilder.com
【问题讨论】:
-
提供一些生成 404 的 URL 示例?
-
感谢您的快速响应链接是http://dailydealbuilder.com/whitepapers.html,您可以在网站http://dailydealbuilder.com/ 的页脚查看所有此类链接,但该链接无效。
标签: wordpress apache .htaccess mod-rewrite url-redirection