简体   繁体   English

使用.htaccess将子域重定向到根域

[英]Redirect Subdomain to root Domain with .htaccess

I'm having a subdomain: 我有一个子网域:

http://admin.domain.nl

But when i'm going to this site it should redirect me to my DirectAdmin site which is: 但是,当我要转到该站点时,应将我重定向到我的DirectAdmin站点:

http://domain.nl:2222/

How to do this in the .htaccess file? 如何在.htaccess文件中执行此操作?

I've tried the following: 我尝试了以下方法:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:admin\.)?domain\.nl$ [NC]
RewriteRule ^ http://domain.nl:2222/ [L,R]

but it's somehow not working and i'm getting a not found error from T-Online. 但是它以某种方式不起作用,并且我从T-Online得到了一个未发现的错误。 How to fix this? 如何解决这个问题?

Try this rule: 尝试以下规则:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^admin\.domain\.nl$ [NC]
RewriteRule ^/?$ http://domain.nl:2222/ [L,R]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM