aeonmarky
08-15-2004, 10:23 AM
Im trying to have a subdomain on the fly created on the fly, but unfortunately i have no success, i tried using mod_rewrite on .htaccess but still no chance.. please help...
![]() | View Full Version : PHP subdomains on the fly aeonmarky 08-15-2004, 10:23 AM Im trying to have a subdomain on the fly created on the fly, but unfortunately i have no success, i tried using mod_rewrite on .htaccess but still no chance.. please help... SEATi 08-15-2004, 11:41 PM There are 4 steps: 1. Set up an error document in your .htaccess file that redirects every single 404 to a file called maybe redirection.php 2. Add a wildcard DNS record in your zone files, so that [whateverhere].yourdomain.com points to the domain IP. 3. Add a wildcard serveralias in your apache configs by using: ServerAlias *.yourdomain.com 4. Write the following code in your redirection.php file <? $url=$_SERVER["REQUEST_URL"]; $newurl=str_replace(".yourdomain.com","",$url); $newcomplete="http://yourdomain.com/".$newurl; Header("Location: ".$newcomplete); ?> So when someone enters a subdomain, let's say myself.yourdomain.com they get redirected to yourdomain.com/myself. aeonmarky 08-16-2004, 12:57 AM Thanks for the reply, The server alias do the trick.. :) thanks fabio!!! Best Regards, Mark SEATi 08-16-2004, 05:14 AM You're welcome, it's glad to know that info helped :) MODS: I guess this thread can be closed |