[英]How can I redirect from one subdomain to another in .htaccess?
Recently we changed the name of a subdomain, now we need to redirect all the old pages to the new subdomain pages. 最近,我们更改了子域的名称,现在我们需要将所有旧页面重定向到新的子域页面。
Example page links: 页面链接示例:
Old URL: http://jquery.webcodehelpers.com/2013/08/what-does-dollar-sign-means-in-jquery.html 旧网址: http : //jquery.webcodehelpers.com/2013/08/what-does-dollar-sign-means-in-jquery.html
New URL: http://uieiq.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
My findings: when I try to access the subdomain in the top level it is working good. 我的发现:当我尝试访问顶级子域时,它运行良好。
How can I redirect all URLs on the old subdomain to the new subdomain? 如何将旧子域上的所有URL重定向到新子域?
currently i have the below code in .htaccess file , please guide to solve the problem 目前我在.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]
Enable mod_rewrite
and .htaccess
through httpd.conf
and then put this code in your DOCUMENT_ROOT/.htaccess
file: 通过
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]
This worked for me, and maintains the URI: 这为我工作,并维护URI:
RewriteCond %{HTTP_HOST} ^jquery\.webcodehelpers\.com
RewriteRule (.*)$ http://uieiq.webcodehelpers.com/$1 [R=301,L]
I used this to redirect a subdomain to another subdomain. 我用它来将一个子域重定向到另一个子域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.