Jump to content

sub domains httacces


mega5network

Recommended Posts

I am planning to make the following schema :

www.example1.domain.com    is  www.domain.com/site/index.php?u=example1

www.example2.domain.com    is  www.domain.com/site/index.php?u=example2

..

 

using PHP code, and httacces, i want to make this dynamic, so any user registred in my domain.com, can have his own website example3.domain.com which read from the file /site/index.php?u=example3

 

Please any help?

Link to comment
Share on other sites

1. Add a wildcard DNS entry for *.domain.com that points to www.domain.com.

2. In your .htaccess, do URL rewriting with the added stipulation that the hostname (%{HTTP_HOST}) must match the "www.([a-z0-9]+).domain.com" pattern. You can pass the name to your PHP script with %1, or have it determine the hostname itself.

3. ???

4. Profit!

Link to comment
Share on other sites

i think i got the solution, i don't know how much it's effective,

1- i added a wildcard DNS *.mega5network.com to /site/ folder

2- in /site/ folder, i put index.php which parse the subdomain, get the user and then save it into the session and direct to /1 folder (1 mean theme number 1)

3- in /1/index.php , i read the user saved in the session and retrieve his website data

 

so if he type : www.john.mega5network.com , it's the same of www.mega5network.com/site/index.php?user=john .

the final URL will be in the address bar :

www.john.mega5network.com/1/index.php

 

but it will be better if i could hide the 1 or 2 or.. the number of theme!!

Link to comment
Share on other sites

The only time the address bar will change URL is if in a RewriteRule you (a) use the [R] flag or (b) give a full destination URL including http:// and whatnot. So if you don't do either of those then the URL as shown to the user will not change.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.