![](/img/trans.png)
[英]How can I make Wordpress redirect all requests to subdomain.domain1.com to www.domain2.com
[英]How can i redirect my subdomain with www to main domain?
我已将我的博客网站从http://www.blog.pixel2pixeldesign.com/更改为https://pixel2pixeldesign.com
现在所有旧帖子都不会重定向到我的新域,因为它将 www.blog 视为我的新子域。
你能帮我使用 .htaccess 代码将http://www.blog.pixel2pixeldesign.com/creative-unique-business-cards/重定向到https://pixel2pixeldesign.com/creative-unique-business-cards/
这是我的 .htaccess 代码
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteCond %{HTTP_HOST} ^pixel2pixeldesign\.com [OR]
RewriteCond %{HTTP_HOST} ^www\.pixel2pixeldesign\.com [OR]
RewriteCond %{HTTP_HOST} ^p2ptuts\.com [OR]
RewriteCond %{HTTP_HOST} ^www\.p2ptuts\.com [OR]
RewriteCond %{HTTP_HOST} ^psd\.p2ptuts\.com [OR]
RewriteCond %{HTTP_HOST} ^www\.psd\.p2ptuts\.com [OR]
RewriteCond %{HTTP_HOST} ^vector\.p2ptuts\.com [OR]
RewriteCond %{HTTP_HOST} ^www\.vector\.p2ptuts\.com
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
在 .htaccess 文件上,您可以执行以下操作:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.blog\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1$1 [R=301,L]
如果您可以访问 apach 配置,则使用重定向指令创建一个新的虚拟主机,例如
Redirect permanent / http://pixel2pixeldesign.com/
性能会更好。
以下代码将 301 重定向到您网站的 www 版本
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.