Jump to content


Dynamic Subdomains


11 replies to this topic

#1 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 15 March 2008 - 10:37 PM

I have searched these forums, google and the site tutorials high and low and couldnt find the answer to my question. Im looking for a way to make dynamic subdomains that dont really exist point to a user page.

So need it to do something like this:

username.site.com is actually www.site.com/profile.php?name=username

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 15 March 2008 - 10:55 PM

http://www.webmaster...orum92/1948.htm

Maybe that will help (or at least the link in the 2nd post).

#3 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 16 March 2008 - 11:29 AM

i dont understand any of that stuff that they're talking about...i just need the chunk of code to add to my htaccess file lol.

#4 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 16 March 2008 - 12:34 PM

View PostHip Hop Artist, on Mar 16 2008, 04:29 PM, said:

i dont understand any of that stuff that they're talking about...i just need the chunk of code to add to my htaccess file lol.

Alternatively you could try and learn something...you know what you want (dynamic/virtual subdomains) and you have just shown you know how to do it (by using .htaccess) so instead of getting people to do things for you take the initiative and search..

Edited by Matthew., 16 March 2008 - 12:34 PM.


#5 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 16 March 2008 - 12:43 PM

Slow down there matthew.

View PostHip Hop Artist, on Mar 15 2008, 09:37 PM, said:

I have searched these forums, google and the site tutorials high and low and couldnt find the answer to my question.
He claims to have searched already. So he may have just been looking for the wrong things at the time.

In the future, please try to be more polite, we're not here to ridicule people for not knowing how to use google.

#6 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 16 March 2008 - 12:54 PM

Sorry Hip Hop Artist, having a crap series of days haha....I should have read your post in its entirety.

You might want to take a look at these two posts...seem pretty helpful.

http://www.webdevelo...ad.php?t=104901
http://forums.devarticles.com/advanced-web...main-24296.html

#7 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 16 March 2008 - 12:56 PM

np we all have our days thanks for the help, these sites look like they have what i want yet when i throw them into my htaccess file they dont work at all....is there something wrong with my server?

Edited by Hip Hop Artist, 16 March 2008 - 01:19 PM.


#8 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 16 March 2008 - 02:49 PM

When you say they don't, does nothing happen at all or do you get an error or any kind? (might be a good idea to check the error logs even if you don't see one)

If the rewrite module was disabled on your server then I believe you get a 501 error shot back at you which makes me inclined to think that's not the problem, however I have read about wildcard DNS having to be enabled on the server on some of the sites I quickly looked at. Couldn't really guess any further than that, subdomains using this method is something I haven't actually done myself. Are you sure you are modifying the code right to work with your setup (e.g. the domain)?

Edited by Matthew., 16 March 2008 - 02:49 PM.


#9 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 16 March 2008 - 05:58 PM

i just get a page that says Server not found. I dont even think its connecting to my site at all. Mabe wildcard does need to be turned on. is there a way to do it from the cpanel to my own account?

#10 Hayden

    P2L Jedi

  • Members
  • PipPipPip
  • 716 posts
  • Gender:Male
  • Location:Texas

Posted 17 March 2008 - 12:14 AM

I tried one of the links and it had something that somewhat worked but I thought, "What if I don't want the user to see the redirect?"

RewriteEngine On

# Extract the subdomain part of domain.com
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.tld$ [NC]

# Check that the subdomain part is not www and ftp and mail
RewriteCond %1 !^(www|ftp|mail)$ [NC]

# Redirect all requests to a php script passing as argument the subdomain
RewriteRule ^(.*)$ index.php?u=%1 [L]

There's what I came up with. :lol:

#11 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 17 March 2008 - 09:56 PM

ill try that thnx!

still same error page...

Edited by Hip Hop Artist, 17 March 2008 - 10:08 PM.


#12 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 17 March 2008 - 10:14 PM

The server not found would probably imply that wildcard DNS is not enabled on your server.

I found the following article explains what wildcard dns is quite well (at least to me).
http://en.wikipedia....card_DNS_record





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users