我怎样才能从一个子域名重定向到另一个在.htaccess? [英] How can I redirect from one subdomain to another in .htaccess?
问题描述
最近,我们改变了一个子域的名称,现在我们需要重定向所有的旧网页到新的子域名的页面。
例如网页链接:
-
旧网址:http://jquery.web$c$chelpers.com/2013/08/what-does-dollar-sign-means-in-jquery.html
-
新网址:http://uieiq.web$c$chelpers.com/2013/08/what-does-dollar-sign-means-in-jquery.html
我的发现:当我尝试访问的子域的顶层是工作好
要如何把旧子域中的所有网址到新的子域名?
目前,我有以下code的.htaccess文件,请引导来解决问题。
RewriteEngine叙述上
的RewriteCond%{HTTP_HOST} ^ jQuery的\名.web codehelpers \ .COM $ [OR]
的RewriteCond%{HTTP_HOST} ^ WWW \ .jquery \名.web codehelpers \ .COM $
重写规则^ / $?HTTP \:\ / \ / uieiq \名.web codehelpers \ .COM \ /搜索\ /标签\ / jQuery的\访谈\问题[R = 301,L]
启用的mod_rewrite
和的.htaccess
到的httpd.conf
,然后把这个code在 DOCUMENT_ROOT /的.htaccess
文件:
RewriteEngine叙述上
的RewriteCond%{HTTP_HOST} ^ jQuery的\名.web codehelpers \ .COM $ [NC]
重写规则^ HTTP://uieiq.web$c$chelpers.com% {REQUEST_URI} [L,R = 301,NE]
请阅读: URL重写简介
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
New URL: 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?
currently i have the below code in .htaccess file , please guide to solve the problem
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:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^jquery\.webcodehelpers\.com$ [NC]
RewriteRule ^ http://uieiq.webcodehelpers.com%{REQUEST_URI} [L,R=301,NE]
Please read: Apache mod_rewrite Introduction
这篇关于我怎样才能从一个子域名重定向到另一个在.htaccess?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!