Wordpress:htaccess重定向(301)无效

时间:2014-03-22 17:31:28

标签: regex wordpress .htaccess mod-rewrite redirect

我有一项令我疯狂的任务:我有一个旧博客,想要为我的新博客创建301重定向,因为我将部分内容移到新域名。

我们可以在example.com/this-is-my-post上找到我的一篇旧帖子,访问者应该重定向到example.org/my-old-post-2817。

我试过的是:

# BEGIN Redirect

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING}  ^$
RewriteRule ^this-is-my-post$ http://example.org/my-old-post-2817 [R=301]
</IfModule>

# END Redirect

问题是FF(桌面),Chrome(Android)和标准互联网浏览器(Android)中没有重定向。在IE(桌面)中,我收到一条错误消息,指出该页面无法显示。没有理由。

我确保.htaccess中没有任何不必要的空白行,为了安全起见,删除了浏览器的历史记录,缓存等等。

我的提供商的CCA给我留言,他重新保存了mod重写模块,我必须在15分钟后再试一次。没有成功。

那么,我错了什么?

此致

松脆

1 个答案:

答案 0 :(得分:0)

更改规则的顺序,以便在内部WP规则之前保留R=301规则:

RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING}  ^$
RewriteRule ^this-is-my-post/?$ http://example.org/my-old-post-2817 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]