切换主机,与.htaccess 301有问题从旧网站重定向到新网站

时间:2013-01-21 11:50:28

标签: php wordpress .htaccess redirect http-status-code-301

我有一个最初建立在blogengine.net上的博客;我切换到Wordpress,并改为另一家托管公司。

我正在使用他们的Cpanel重定向3或4页以反映他们的新网址。具体来说,我在一个实例中试图烫发301重定向:

http://www.realtruthnow.org/blog/post/2013/01/01/What-do-people-in-Newtown-want-for-the-holidays

http://www.realtruthnow.org/ny-governor-signs-nations-first-gun-control-bill-since-newtown/

当我使用主机的Cpanel执行此操作时,它会在我的root .htaccess中创建一个条目,如下所示:

RewriteCond %{HTTP_HOST} ^realtruthnow\.org$ [OR]
RewriteCond %{HTTP_HOST} ^www\.realtruthnow\.org$
RewriteRule ^blog\/post\/2013\/01\/01\/What\-do\-people\-in\-Newtown\-want\-for\-the
\-holidays$ "http\:\/\/www\.realtruthnow\.org\/ny\-governor\-signs\-nations\-first
\-gun\-control\-bill\-since\-newtown\/" [R=301,L]

这不起作用。所以我用Google搜索,并尝试将它放在.htaccess的底部:

Options +FollowSymLinks
RewriteEngine on
Redirect 301 /http://www.realtruthnow.org/blog/post/2013/01/01/What-do-people-
in-Newtown-want-for-the-holidays http://www.realtruthnow.org/ny-governor-signs-nations-
first-gun-control-bill-since-newtown/

这也不起作用。我只需要为我知道的3或4页做这个。有没有人知道如何完成从旧主机到新主机的重定向,所以当有人点击旧链接时,他们会对新链接进行301会话?任何指导将不胜感激!

解决

我安装了“简单301重定向”插件,当我将旧网址http://www.realtruthnow.org/放入其中时,这不起作用...但是当我省略它时,只需输入/ blog / post / 2013/01 / 01 / Newtown-what-do-people-in-Newtown-want-for-the-holiday in my old URL,BAM - 它有效!如果有人需要,下面是插件。

http://wordpress.org/extend/plugins/simple-301-redirects/

2 个答案:

答案 0 :(得分:1)

你可以试试这个;

RewriteCond %{HTTP_HOST} ^realtruthnow\.org$ [OR]
RewriteCond %{HTTP_HOST} ^www\.realtruthnow\.org$
RewriteRule ^blog/post/2013/01/01/What-do-people-in-Newtown-want-for-the-holidays/?$  http://www.realtruthnow.org/ny-governor-signs-nations-first-gun-control-bill-since-newtown/ [R=301,L,NC]

这与cPanel生成的规则相同,没有引号和转义。

它会永久重定向

http://www.realtruthnow.org/blog/post/2013/01/01/What-do-people-in-Newtown-want-for-the-holidays

到此

http://www.realtruthnow.org/ny-governor-signs-nations-first-gun-control-bill-since-newtown/

答案 1 :(得分:0)

如果有人遇到类似问题,我解决了将旧的blogengine.net链接(从Windows服务器)重定向到新主机的Wordpress链接的问题。

事实证明,它是一种古怪的Wordpress类型。

我安装了"简单的301重定向"插件,当我将旧的整体网址http://www.realtruthnow.org/blog/post/2013/01/01/What-do-people-in-Newtown-want-for-the-holidays放入...时,该功能无效。

但是当我省略了根,只是把/ blog / post / 2013/01/01 / What-do-people-in-Newtown-want-for-the-holidays用于我的旧网址,BAM - 有效!

如果有人需要,下面是插件。

http://wordpress.org/extend/plugins/simple-301-redirects/

相关问题