简体   繁体   中英

Redirect a domain request to a subfolder

I am trying to redirect a domain to a subfolder within the same server. Let me break it down on topics:

  1. I have the domain domain.com
  2. I created the subdomain subdomain.domain.com
  3. I redirected (A record) subdomain.domain.com to the domain.com server's IP address
  4. I am trying to create a htaccess file that redirects every user that comes from subdomain.domain.com to domain.com/aaa

I can't figure out how though. I suppose I need to create a rewriting rule but don't know how.

To Redirect sub.example.com to example.com/folder you can use the following Rule in your /public_html/. htaccess /public_html/. htaccess

 RewriteEngine on

RewriteCond %{HTTP_HOST} ^sub\.example\.com$ [NC]
RewriteRule (.*) http://example.com/folder/$1 [L,R=301,NE]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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