mega5network Posted May 24, 2012 Share Posted May 24, 2012 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 https://forums.phpfreaks.com/topic/263068-sub-domains-httacces/ Share on other sites More sharing options...
requinix Posted May 24, 2012 Share Posted May 24, 2012 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 https://forums.phpfreaks.com/topic/263068-sub-domains-httacces/#findComment-1348430 Share on other sites More sharing options...
mega5network Posted May 24, 2012 Author Share Posted May 24, 2012 Please may you write here the syntax in the .htaccess file? i added the wildcard, you can see here http://www.tester.mega5network.com/test.php work. but how i will direct it to http://www.mega5network.com/site/index.php?user=tester ? Link to comment https://forums.phpfreaks.com/topic/263068-sub-domains-httacces/#findComment-1348433 Share on other sites More sharing options...
mega5network Posted May 24, 2012 Author Share Posted May 24, 2012 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 https://forums.phpfreaks.com/topic/263068-sub-domains-httacces/#findComment-1348439 Share on other sites More sharing options...
requinix Posted May 25, 2012 Share Posted May 25, 2012 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 https://forums.phpfreaks.com/topic/263068-sub-domains-httacces/#findComment-1348661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.