MilesWeb Hosting Forum

Web Hosting Technical Support => How To's => Topic started by: Dipak Bhoi on September 18, 2014, 05:11:47 PM

Title: How to set redirect from dynamic URL to suddomain ?
Post by: Dipak Bhoi on September 18, 2014, 05:11:47 PM
Hello Guys,

If you wish to re-direct the dynamic URL to corresponding sub-domain then let see how you can achieve this:

First you need to know the Dynamic URL pattern:
Quote
http://yourdomain.com/page.php?user_name=user1

Here in above URL word user1 is not a specific . It will change every time. And below is a URL that you wish to re-direct this URL to below corresponding sub domain.

Quote
http://user1.yourdomain.com/

Let see how you can do this :

1. First you need to set wildcard for your domain. You can do this by simply edit the line in your virtualhost configuration in httpd.conf file. Set it as below.

Quoteserver alias *.yourdomain.com

2. Save the file and restart httpd service.

3. Now write the below code into your .htaccess file.

QuoteRewriteEngine on
RewriteCond %{HTTP_HOST} ^([a-z])\.yourdomain\.com [NC]
RewriteRule ^(.*)$ /user1 [R=301,L]


Now it will redirect like something.yourdomain.com => yourdomain.com/user1.

That's all.

Enjoy !!