简体   繁体   中英

Redirecting subdomain without changing URL using .htaccess

wondering if you can help me with some .htaccess.

I want to have sub.example.com display data from example.com/sub without changing the URL : ie. sub.example.com will stay sub.example.com although it is reading from example.com/sub

I have the following data in .htaccess:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub.example.com
RewriteRule ^(.*)$  http://example.com/sub/$1 [L,NC,QSA]

I tried to change the [L,NC,QSA] to [P] but I get an error 403 - forbidden access.

Any help would be appreciated!

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

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