我怎样才能从一个子域名重定向到另一个在.htaccess? [英] How can I redirect from one subdomain to another in .htaccess?

查看:159
本文介绍了我怎样才能从一个子域名重定向到另一个在.htaccess?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我们改变了一个子域的名称,现在我们需要重定向所有的旧网页到新的子域名的页面。

例如网页链接:

我的发现:当我尝试访问的子域的顶层是工作好

要如何把旧子域中的所有网址到新的子域名?

目前,我有以下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:

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屋!

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