I want visitors to redirect from a subdomain to another subdomain using masking.
I have a folder demo in my root web root example.com . when user logs in a subdomain will be created by taking his input name, say mystore and he will get mystore.example.com . I want him to redirect to demo folder(subdomain) but he should not know this. Even after redirecting he should get mystore.example.com .
Is it possible with domain masking? How do I do this and where should I write the code?
Actually that is Subdomain Wildcard and your host must have it enabled and you can create dynamically subdomains using .htaccess
:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule ^$ http://www.example.com/demo/?store_name=%2 [L]
This will mean that mystore.example.com
will actually go to http://www.example.com/demo/?store_name=mystore
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.