Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 13 of 13

This is a discussion on "fake" subdomains in the Shared & Semi-Dedicated forum
Holah, Is it possible to make "fake" subdomains so that when you load tehSub.yoursite.com it actually just goes to for instance www.yoursite.com/filename.php?var=tehSub . right now ...

  1. #1
    Smo
    Smo is offline
    JPC Addict
    Join Date
    Nov 2002
    Location
    Finland
    Posts
    218

    "fake" subdomains

    Holah,
    Is it possible to make "fake" subdomains so that when you load tehSub.yoursite.com it actually just goes to for instance www.yoursite.com/filename.php?var=tehSub. right now if i try to load sub.mysite.com FF gives a "could not be found" message.

    I'd asume that there is some .htaccess tweekage to be done to get this to work, but I have no idea what.

  2. #2
    Smo
    Smo is offline
    JPC Addict
    Join Date
    Nov 2002
    Location
    Finland
    Posts
    218
    I tested on VinDSLs page and it works there.

    http://blabla.lenon.com works
    http://blabla.killboredom.com doesn't

    (lenon.com was the only Jaguar hosted site I could think off -.-)

  3. #3
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    Sure! You can do anything with .htaccess, given enough time and effort...
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

  4. #4
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    Quote Originally Posted by Smo
    I tested on VinDSLs page and it works there.

    http://blabla.lenon.com works...
    Heh! Try it now...
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

  5. #5
    Smo
    Smo is offline
    JPC Addict
    Join Date
    Nov 2002
    Location
    Finland
    Posts
    218
    Hehe
    Now the question is what do I add to .htaccess so that it'll redirrect instead of block. The php part of checking the subdomain and using it as a variable I can do, but I've never done much .htaccess editing.

  6. #6
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    Yeah, .htaccess is kinda funny. It like losing weight...

    Everyone knows how to lose weight, right? It's very simple! Ask anyone and they can tell you. However, losing weight is very hard. It's very simple, but very hard -- .htaccess is the same thing -- easy but hard.

    OMG! I'm starting to sound like Richard Simmons...
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

  7. #7
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    The "not found" message is coming from the DNS system, not from Apache. When you make a request for a domain name, your computers DNS resolver kicks in and tries to look up that specific name (blabla.killboredom.com). If it can't find that specific name somewhere in the DNS system, it'll return an error, and that is wht you are seeing right now.

    To get around this, you need to do one of two things. You can either set up a new "A" record (a DNS Address record) for every "fake" subdomain you wnt to use, or you can set up a wildcard record. The wildcard works much like the email catch all: when a request comes in to the DNS server, the server goes through your zone record searching for the requested name. If it comes to a "*" in the list of addresses it stops and sends back the IP address associated with it.

    Since you only have one IP address, shared by each subdomain on your site, your main site, and possibly everyone else on the server as well, Apache needs to do some work as well. Once the IP address is found, the browser's request is sent to the server. A "host" variable is sent along, specifying which specific host name was requested. Apache scans its list of sites looking for that name. If it is found, it serves up the proper page. If not it goes through a similar process of sending you to a default site. Once you get to that default site you .htaccess rules will kick in and you cna use mod_rewrite to manipulate the URL.

    The rewrite would be something like this (not tested):

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^tehsub\.yoursite\.com$ [NC]
    RewriteRule ^/(.*) http://www.yoursite.com/filename.php?var=tehsub [QSA,R,L]

    In this example, the subdomain would be redirected to filename.php every time, regardless of the path you entered after the filename. Replacing filename.php with $1 will cause you to keep the path as is, but redirect to the www domain and attach "tehsub" as a variable. (this would probably be overkill as you can find the host name used through PHP with $_SERVER['HTTP_HOST']). You could also set your RewriteRule to http://www.yoursite.com/tehsub/$1, which would cause the server to look for the files in the "tehsub" directory, essentially doing the same thing as a real subdirectory.

    Hope this helps.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  8. #8
    Smo
    Smo is offline
    JPC Addict
    Join Date
    Nov 2002
    Location
    Finland
    Posts
    218
    To get around this, you need to do one of two things. You can either set up a new "A" record (a DNS Address record) for every "fake" subdomain you wnt to use, or you can set up a wildcard record. The wildcard works much like the email catch all: when a request comes in to the DNS server, the server goes through your zone record searching for the requested name. If it comes to a "*" in the list of addresses it stops and sends back the IP address associated with it.
    Thanks for the reply, it makes sence, but..

    As a true DNS & .htaccess n00b, I'd need some more exact help with that wildcard part. Where do I put the '*' wildcard and in what form. (I use aletianic)

    The .htaccess I can figure out based on the example you gave me, and google.

  9. #9
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    Sorry, about that...I forgot to mention that you'll need to contact support for DNS chagnes. You don't have access to the DNS settings.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  10. #10
    Smo
    Smo is offline
    JPC Addict
    Join Date
    Nov 2002
    Location
    Finland
    Posts
    218
    Heh, np, thanks for the help

  11. #11
    JPC Guru
    Join Date
    Jan 2004
    Location
    I'm right behind you....
    Posts
    389
    This is very easy and Jason had it right already. I use .htaccess to give subdomains to my multihosted domains (since they can't have "real" subdomains). This code is tested and works:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} .*subdomain.doman\.com$
    RewriteCond %{REQUEST_URI} !^/path_to/directory/for_subdomain/
    RewriteRule (.*) /path_to/directory/for_subdomain/$1

    That would make any request for subdomain.domain.com go to domain.com/subdomain/ and it will be transparent to the end user.

    Hope that helps, good luck

  12. #12
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    Quote Originally Posted by Smo
    The .htaccess I can figure out based on the example you gave me, and google.
    Since you're interested in this kinda stuff, here's a cute 'example' for you. Maybe it'll give you some ideas, for future reference...

    I recently found out my registrar had given me a free '.info' TLD, so I used it to test the multi-hosted domain feature here on JagPC. The way it used to be, you had to contact Tech Support to get these multi-hosted domains setup. Now, you can do it yourself via cPanel.

    Everything worked great, but because multi-hosted domains set inside subdomains, you could call up the URL many different ways -- and it looked rather amateur-ish, IMHO. Besides that, I knew those damn search bots would find every one of them... So, I used .htaccess to force all calls to the TLD.

    Here's .htaccess file I use in my multi-hosted directory...
    Code:
    # $Author: VinDSL (Lenon.com) $
    # $Date: 2005/09/10 15:27:43 $
    
    #Don't inherit parent '.htaccess' config
    RewriteEngine on
    
    #Redirect all multi-hosted 'lenon.info' permutations to http://lenon.info/
    RewriteCond %{REQUEST_URI} ^info\.lenon\.com$                    [NC,OR]
    RewriteCond %{HTTP_HOST} ^info\.lenon\.com$                      [NC,OR]
    RewriteCond %{HTTP_HOST} ^www\.lenon\.info$                      [NC,OR]
    RewriteCond %{HTTP_HOST} ^69.73.147.61$
    RewriteRule ^(.*)$ http://lenon.info/$1                          [R=301,L]
    
    #Failsafe
    Redirect 301 /info  http://lenon.info
    Give it a try:
    Did I miss any?
    Last edited by Vin DSL; 09-10-2005 at 04:28 PM.
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

  13. #13
    Smo
    Smo is offline
    JPC Addict
    Join Date
    Nov 2002
    Location
    Finland
    Posts
    218
    hmm, is the one with the IP address supposed to go to "Requested URL Not Found"?

    I'll start testing this after some proper sleep -.- I also have a multi-hosted domain (killboredom.net) but haven't taken it in use properly yet.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •