1

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 ?

Radhakrishna Rayidi
  • 510
  • 2
  • 9
  • 24

2 Answers2

1

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]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • I believe `dev.mosto.in` and `www.mosto.in` both point to same DOCUMENT_ROOT is it true? And did you try this URL: `http://dev.mosto.in` for testing? – anubhava Sep 12 '13 at 17:21
  • Yes the both points to *`public_html`* and if i open http://dev.mosto.in is says **`Firefox can't find the server at dev.mosto.in.`** – Radhakrishna Rayidi Sep 12 '13 at 17:24
  • If you're getting that error then it means your wildcard domain is not setup properly. – anubhava Sep 12 '13 at 17:25
  • Ohh let me check with my Hosting people and post back to you, thanks for helping me dude. – Radhakrishna Rayidi Sep 12 '13 at 17:26
  • Even `dig dev.mosto.in` or `nslookup dev.mosto.in` are failing so I guess you need to work with your hosting co regarding this. – anubhava Sep 12 '13 at 17:26
  • If this answer helped you solve your problem, please consider marking it as "accepted", so users facing a similar problem in the future will be able to see it easily. – anubhava Sep 13 '13 at 11:05
0
RewriteEngine On

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

Fixed my problem.

Radhakrishna Rayidi
  • 510
  • 2
  • 9
  • 24