htaccess的重定向子域的根域 [英] htaccess redirect subdomain to root domain

查看:135
本文介绍了htaccess的重定向子域的根域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要重定向该子:

  http://abc.domain-name.com
 

要在使用相同名称的根域文件夹:

  http://www.domain-name.com/abc
 

这样,如果我尝试访问以下文件:

  http://abc.domain-name.com/folder/file.html
 

它会去:

  http://www.domain-name.com/abc/folder/file.html
 

解决方案

试试这个:

  RewriteEngine叙述上
的RewriteCond%{HTTP_HOST} ^子域\ .yourdomain \ .COM
(。*)重写规则^ $ HTTP:// WWW \ .yourdomain \ .COM /子域/ $ 1 [L]
 

(从 http://systembash.com/content/simple -redirect子域到一个目录/

I want to redirect this subdomain:

http://abc.domain-name.com

to a folder on the root domain that uses the same name:

http://www.domain-name.com/abc

This way, if I try to access the following file:

http://abc.domain-name.com/folder/file.html

It will go to:

http://www.domain-name.com/abc/folder/file.html

解决方案

Try this:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\.yourdomain\.com
RewriteRule ^(.*)$ http://www\.yourdomain\.com/subdomain/$1 [L]

(from http://systembash.com/content/simple-redirect-subdomain-to-a-directory/)

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

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