简体   繁体   English

.htaccess将所有页面和URL从旧域重定向到新域

[英].htaccess redirect all pages and url from old domain to new domain

to be very honest I have zero knowledge with Regex and .htaccess 老实说,我对Regex和.htaccess的知识为零

somewhere I found this code sample to redirect the user from old domain to new domain and it works fine 在某个地方,我发现此代码示例将用户从旧域重定向到新域,并且工作正常

RewriteCond %{HTTP_HOST} ^(www\.)?old\.com$ [NC]
RewriteRule ^(.*)$ http://www.new.com/$1 [R=301,L]

But what is the issue here is when I access any page like www.old.com/courses it remains there rather of redirecting it to www.new.com/courses 但是这里的问题是,当我访问任何页面(如www.old.com/courses)时,它仍然存在,而不是将其重定向到www.new.com/courses。

It is a wordpress site and it has thousand of such sub/internal pages. 这是一个wordpress网站,它具有数千个此类子/内部页面。

确保您所有wordpress规则之前都有这些规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM