htaccess redirect subdomain to root domain

后端 未结 2 1158
無奈伤痛
無奈伤痛 2021-01-18 08:00

I want to redirect this subdomain:

http://abc.domain-name.com

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

http:         


        
相关标签:
2条回答
  • 2021-01-18 08:40

    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/)

    0 讨论(0)
  • 2021-01-18 08:42

    You should consider about search engines and use permanent redirect (301), also its best practice to use NC flag at the end if second line to be matched in a case-insensitive manner.

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^blog\.example\.com  [NC]
    RewriteRule ^(.*) http://www.example.com/$1 [L,R=301]
    
    0 讨论(0)
提交回复
热议问题