Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
重定向整个Wordpress站点良好实践_Wordpress_.htaccess - Fatal编程技术网

重定向整个Wordpress站点良好实践

重定向整个Wordpress站点良好实践,wordpress,.htaccess,Wordpress,.htaccess,我已经克隆了一个完整的wordpress网站——我们称之为x.com。我在一个新网站上安装了这个克隆,让我们调用y.com 不,我需要在.htaccess中进行重定向。我试着用这个,它给了我500个内部错误: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{RE

我已经克隆了一个完整的wordpress网站——我们称之为x.com。我在一个新网站上安装了这个克隆,让我们调用y.com

不,我需要在.htaccess中进行重定向。我试着用这个,它给了我500个内部错误:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

RewriteEngine on 
RewriteRule ^(.*)$ http://y.com/$1 [R=301,L]

重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
重新启动发动机
重写规则^(.*)$http://y.com/$1[R=301,L]

那么,当x.com/product/cream被重定向到y.com/product/cream等时,我如何进行适当的重定向呢?

第一个块是导致Wordpress引擎处理大量URL的原因。您应该只在VirtualHost或
y.com
的.htaccess文件中拥有此块,您现在所在的网站是Wordpress的宿主

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

请记住,测试时应仅使用临时重定向(302),因为永久重定向(301)由浏览器缓存,这会导致浏览器在自己的缓存中查找结果,而不是向服务器请求新的重定向。当您对结果满意时,通过将
R
更改为
R=301
将规则更改为永久重定向。非常感谢您的回答。因此,我将删除第一个块并在RewriteRule^(.*)上插入
RewriteEngine$http://y.com/$1[R,L]
。该块将把每一页从旧页重定向到新页,对吗
x.com/products/cream重定向到
y.com/products/cream`等
RewriteEngine on 
RewriteRule ^(.*)$ http://y.com/$1 [R,L]