重定向到新的域时的.htaccess重写规则,以保持子域 [英] .htaccess rewrite rule to keep subdomains when redirecting to new domain

查看:116
本文介绍了重定向到新的域时的.htaccess重写规则,以保持子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正从旧域中的网站有几个子域到一个新的领域。我想创建一个重写规则,这将只是换了旧的域名为新的,但我不与普通的前pressions及放够精明; htaccess的做到这一点:P

I am moving a site from an old domain with several subdomains to a new domain. I'd like to create a rewrite rule that will just swap out the old domain for the new one, but I am not savvy enough with regular expressions & .htaccess to do this :P

我可以得到301重定向工作在域的网页:

I can get the 301 redirect working for the pages on the domain:

RewriteCond %{HTTP_HOST} ^(.*)oldomain.org [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]

如何修改这包含子以及任何线索?还是我卡住列出所有的子域单独重写?

Any clues on how to modify this to include the subdomain as well? Or am I stuck listing all the subdomains in separate rewrites?

推荐答案

您只需要添加一个%1

RewriteCond %{HTTP_HOST} ^(.*)oldomain.org [NC]
RewriteRule ^(.*)$ http://%1newdomain.com/$1 [R=301,L]

这篇关于重定向到新的域时的.htaccess重写规则,以保持子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆