hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Programming Tutorials : PHP subdomains on the fly
Reply

Programming Tutorials How-Tos related to programming, databases, and the like.
Forum Jump

PHP subdomains on the fly

Reply Post New Thread In Programming Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 08-15-2004, 10:23 AM
aeonmarky aeonmarky is offline
New Member
 
Join Date: Aug 2004
Location: PH
Posts: 4

PHP subdomains on the fly


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...

Reply With Quote


Sponsored Links
  #2  
Old 08-15-2004, 11:41 PM
SEATi SEATi is offline
Web Hosting Master
 
Join Date: Jul 2003
Posts: 656
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.

Reply With Quote
  #3  
Old 08-16-2004, 12:57 AM
aeonmarky aeonmarky is offline
New Member
 
Join Date: Aug 2004
Location: PH
Posts: 4
Thanks!

Thanks for the reply,

The server alias do the trick.. thanks fabio!!!


Best Regards,
Mark

Reply With Quote
Sponsored Links
  #4  
Old 08-16-2004, 05:14 AM
SEATi SEATi is offline
Web Hosting Master
 
Join Date: Jul 2003
Posts: 656
You're welcome, it's glad to know that info helped

MODS: I guess this thread can be closed

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Aussie Web Host DWHS Rebrands to WebHost.pro, Adds Plans and Features Web Hosting News 2013-02-14 14:41:25
Microsoft Reaches Settlement with Nitol Botnet Host 3322.org Web Hosting News 2012-10-05 13:13:16
Web Hosting Sales and Promos Roundup – June 22, 2012 Web Hosting News 2012-06-22 16:36:15
LulzSec Hackers Retaliate After Arrests, Deface Dozens of Panda Security Subdomains Web Hosting News 2012-03-08 10:41:26
Linux Foundation Website Down After Security Breach Last Week Web Hosting News 2011-09-12 20:32:11


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?