Question

Hie all,

I'm trying to make a dynamic sub domains for my users like username.host.com instead of www.host.com/user.php?user=username

For that i created a A RECORD in my hosting like *.mosto.in 208.91.199.44 Active

In my .htaccess file i've added the following

RewriteEngine on
RewriteCond   %{HTTP_HOST}                 ^www\.[^.]+\.mosto\.in$
RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
RewriteRule   ^www\.([^.]+)\.mosto\.in(.*) /home/$1$2

The above code i found on Apache official website http://httpd.apache.org/docs/2.0/misc/rewriteguide.html#content

But when i trying to open dev.mosto.in is not opening.

Any clues or ideas ? Where i'm doing wrong ?

Was it helpful?

Solution

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.
RewriteRule ^$ http://www.mosto.in/user.php?user=%1 [L,QSA,R]

OTHER TIPS

RewriteEngine On

# Redirecting wildcard subdomains to store.php
RewriteCond %{HTTP_HOST} ^(^.*)\.mosto.in
RewriteRule (.*)  store.php?store=%1

Fixed my problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top