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

This is a discussion on mod_rewrite wildcard subdomain in the Shared & Semi-Dedicated forum
I didn't know where this should go. anyways you apache guru's I am trying to get mod_rewrite to have a wildcard subdomain to direct users ...

  1. #1
    JPC Member
    Join Date
    Sep 2003
    Location
    Orange County
    Posts
    2

    mod_rewrite wildcard subdomain

    I didn't know where this should go. anyways you apache guru's
    I am trying to get mod_rewrite to have a wildcard subdomain to direct users to a php script.
    something such as
    (www\.)?[^.]+\.mysite\.com /somepage.php?subdomain=$1 [L,T=blah-PHP]
    i have been testing it locally on my apache but i cannot for the life of me get it to function right.
    anyways anyhelp is GREATLY appreciated.

  2. #2
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    First of all, do you have DNS wildcarding set up on your account? You'll need this before anything will work. You can test for it by typing anything.yourdomain.com into your browser. IF you get your usual homepage, you ahve it. If you get an error, you don't.

    Instead of mod_rewrite, consider adding code to your site's hompage that checks requested HTTP_HOST and does the forward from there.

    PHP Code:
    <?
        
    if($_SERVER['HTTP_HOST'] != 'www.yourdomain.com' ||
          
    $_SERVER['HTTP_HOST'] != 'yourdomain.com') {
            
    header("Location: /somepage.php?subdomain=<whatever>");
        }
    ?>
    Page content
    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  3. #3
    JPC Member
    Join Date
    Sep 2003
    Location
    Orange County
    Posts
    2
    Thank you so much. Perfect idea as well.

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
  •