user1711509
user1711509

Reputation: 3

Redirection within domain using masking

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?

Upvotes: 0

Views: 527

Answers (1)

Mihai Iorga
Mihai Iorga

Reputation: 39704

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

Upvotes: 1

Related Questions