WordPress-将网站移至另一个域,301重定向 [英] Wordpress - moving a site to another domain, 301 redirects
问题描述
我将wordpress网站移到了另一个域.我想保留google链接,并帮助它重新索引新站点.
I moved a wordpress site to another domain. I want to preserve the google links however and help it re-index the new site.
我执行了301重定向,但仅适用于根目录主管.当有人去http://oldsite.com/directory/post-name-here/
时,我希望他们被转发到http://newsite.com/directory2/post-name-here/
.这两个网站都在子目录中.有没有办法在PHP中做到这一点?还是我需要一个mod-rewrite?
I did a 301 redirect but it only works for the root director. When someone goes to http://oldsite.com/directory/post-name-here/
I want them to be forwarded to http://newsite.com/directory2/post-name-here/
. Both websites are in subdirectories. Is there a way to do it with in PHP? Or would I need a mod-rewrite?
最终对我有用的是:
我的旧站点文件结构如下:
My oldsite file structure is like so:
/public_html/
index.php
/development/
.htaccess
回顾一下,我想将开发目录中的所有内容转发到新网站.这是development
目录中.htaccess的代码.
To recap, I wanted to forward everything coming into the development directory to the new website. This is the code of the .htaccess in the development
directory.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^oldsite.org$ [OR]
RewriteCond %{HTTP_HOST} ^www.oldsite.org$
RewriteRule (.*)$ http://newsite.com/newdirectory/$1 [R=301,L]
非常感谢Peter
推荐答案
这一直对我有用:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
这篇关于WordPress-将网站移至另一个域,301重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!