Question about subdomains in modrewrite

Discussion in 'Programming' started by Trailerdownload, Jan 8, 2007.

  1. #1
    Hi all,

    I try to get something to work but i just dont get it why it doesnt

    i want this:

    everythingthatstandshere.mydomain.com/$something
    to link to
    www.mydomain.com/$something

    and not one thing but everything that stands before that with all symbols (if possible) included like - (-blabla.mydomain.com)

    I know there is a way to get this in mod rewrite but i just cant figure out how

    Thanks

    Bas
     
    Trailerdownload, Jan 8, 2007 IP
  2. brunozugay

    brunozugay Peon

    Messages:
    150
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It should look something like this:

    RewriteEngine On

    RewriteCond %{SERVER_NAME} !^www\.mydomain\.com$
    RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,NE,R=301]
     
    brunozugay, Jan 9, 2007 IP
  3. Trailerdownload

    Trailerdownload Peon

    Messages:
    297
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Tryed that doesn't work still no connections from my subdomains to my main site

    Thanks
     
    Trailerdownload, Jan 9, 2007 IP
  4. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Is it only rewrite rules you've done?

    A catch all subdomain doesn't actually need mod rewrite in this case - the subdomain is being treated as if it were the main site.

    To get *.domain.com to work you need to do two things:
    1) edit the apache httpd.conf virtualhosts section for the domain and add ServerAlias *.domain.com
    2) add a DNS A record for *.domain.com. (ending with a period)
     
    rodney88, Jan 9, 2007 IP
  5. sgugal

    sgugal Peon

    Messages:
    183
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Right , you have to use Wildcard DNS .
     
    sgugal, Jan 9, 2007 IP