How can i set .htaccess for redirect subdomain to directory
I have php backend and generate root directory same by username when user created
ex. php backend create user xxx my server create /var/www/html/xxx
this process it's completely abc.com/xxx i have done it.
but...
I want to redirect subdomain to directory
subdomain is dynamically from user
xxx.abc.com it's must redirect to abc.com/xxx
how can i set htaccess to do that
You may use this rule in site root .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.(abc\.com)$ [NC]
RewriteRule ^ http://%2/%1%{REQUEST_URI} [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.