![](/img/trans.png)
[英].htaccess 301 redirect one subdomain to another, for multiple TLDs
[英]How can I redirect from one subdomain to another in .htaccess?
最近,我们更改了子域的名称,现在我们需要将所有旧页面重定向到新的子域页面。
页面链接示例:
旧网址: http : //jquery.webcodehelpers.com/2013/08/what-does-dollar-sign-means-in-jquery.html
新网址: http : //uieiq.webcodehelpers.com/2013/08/what-does-dollar-sign-means-in-jquery.html
我的发现:当我尝试访问顶级子域时,它运行良好。
如何将旧子域上的所有URL重定向到新子域?
目前我在.htaccess文件中有以下代码,请指导解决问题
RewriteEngine on
RewriteCond %{HTTP_HOST} ^jquery\.webcodehelpers\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.jquery\.webcodehelpers\.com$
RewriteRule ^/?$ "http\:\/\/uieiq\.webcodehelpers\.com\/search\/label\/jquery\ interview\ questions" [R=301,L]
通过httpd.conf
启用mod_rewrite
和.htaccess
,然后将此代码放入DOCUMENT_ROOT/.htaccess
文件中:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^jquery\.webcodehelpers\.com$ [NC]
RewriteRule ^ http://uieiq.webcodehelpers.com%{REQUEST_URI} [L,R=301,NE]
这为我工作,并维护URI:
RewriteCond %{HTTP_HOST} ^jquery\.webcodehelpers\.com
RewriteRule (.*)$ http://uieiq.webcodehelpers.com/$1 [R=301,L]
我用它来将一个子域重定向到另一个子域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.