.htaccess rewrite subdomain to directory

前端 未结 8 1976
不思量自难忘°
不思量自难忘° 2020-11-22 10:26

Is it possible to use .htaccess to rewrite a sub domain to a directory?

Example:

  • http://sub.domain.com/

shows the content of

8条回答
  •  青春惊慌失措
    2020-11-22 11:10

    This redirects to the same folder to a subdomain:

    .httaccess

    RewriteCond %{HTTP_HOST} !^www\.
    RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
    RewriteRule ^(.*)$ http://domain\.com/subdomains/%1
    

提交回复
热议问题