1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Rewrite a sub domain to a directory

Discussion in 'Apache' started by mnemtsas, Jun 13, 2005.

  1. #1
    mnemtsas, Jun 13, 2005 IP
  2. ZuraX

    ZuraX Active Member

    Messages:
    156
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #2
    If you use cpanel both should work. If you dont I am not sure how to do it but mod_rewrite should work.
     
    ZuraX, Jun 14, 2005 IP
  3. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I figured it out, .htaccess works:

    
    RewriteCond %{HTTP_HOST}   ^[www\.]*sub-domain-name.domain-name.com [NC]
    RewriteCond %{REQUEST_URI} !^/sub-domain-directory/.*
    RewriteRule   ^(.*)  /sub-domain-directory/$1  [L]
    
    Code (markup):
     
    mnemtsas, Jun 14, 2005 IP
  4. THT

    THT Peon

    Messages:
    686
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    so in theory, if i have htaccess access, then i can park as many domains as i want on my account...
     
    THT, Jun 15, 2005 IP
  5. THT

    THT Peon

    Messages:
    686
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ignore me, i misread it
     
    THT, Jun 15, 2005 IP
  6. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Well my webhost allows me to add unlimited type A dns records free of charge. So with .htaccess I can indeed park unlimited domains.
     
    mnemtsas, Jun 15, 2005 IP
  7. sharpweb

    sharpweb Guest

    Messages:
    246
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I'm a full on newbie on this. Here's what I'm trying to do. Any direction would be great:

    subdomain = wanaka.snowcommunity.com
    server path to subdomain = /hsphere/local/home/ccharp/wanaka.snowcommunity.com
    domain = snowcommunity.com
    server path where I want the rewrite to = /hsphere/local/home/ccharp/snowcommunity.com/wanaka/

    I've managed to get a mod_rewrite that redirects wanaka.snowcommunity.com to http://www.snowcommunity.com/wanaka/. But what I'd prefer is for wanaka.snowcommunity.com to remain in the address bar (a rewrite). The trouble is that the subdomains folder is not on the same path as snowcommunity.com

    Here is my mod_rewrite so far:

    RewriteEngine On
    Options Indexes FollowSymlinks Multiviews
    RewriteBase /
    RewriteCond %{HTTP_HOST} wanaka.snowcommunity.com
    RewriteCond %{REQUEST_URI} !wanaka/
    RewriteRule ^(.*)$ http://www.snowcommunity.com/wanaka/$1 [L]
    Code (markup):
     
    sharpweb, Aug 25, 2005 IP
  8. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I don't think that this is possible. According to the manual, if you start your substitution string with http:// then an external redirect is forced. So you cannot rewrite to a file on a different domain, you have to redirect to it. If you're doing this I would recommend using a 301 ( permanent ) redirect, as this will prevent potential problems with the search engine spiders.
     
    johnt, Aug 26, 2005 IP
  9. sharpweb

    sharpweb Guest

    Messages:
    246
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I don't need to go rewrite to a whole new domain. They are both on the same server. Just not on the same path. I've set up a redirect for now (way too frustrated to keep trying) but I'd still be very interested if anyone knows of a solution to this.
     
    sharpweb, Aug 26, 2005 IP
  10. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Can you just set the server path for the subdomain to /hsphere/local/home/ccharp/snowcommunity.com/wanaka/ ? Then you probably wouldn't need mod_rewrite at all
     
    johnt, Aug 26, 2005 IP
  11. sharpweb

    sharpweb Guest

    Messages:
    246
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #11
    I can't do it myself. I've asked my host host once and been denied....I may ask again. That seems like the best/ easiest way. cheers
     
    sharpweb, Aug 26, 2005 IP
  12. jean-david

    jean-david Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I know that you want to use mod rewrite but a simple virtual host would do the job

    just add to /etc/apache2/httpd.conf

    NameVirtualHost [your IP]:80

    <VirtualHost [your IP]:80>
    ServerName building-a-deck.timesheetsmts.com
    DocumentRoot [Path of webapp]
    </VirtualHost>

    Works on Apache right out of the box
     
    jean-david, Jul 13, 2007 IP
  13. Best Domain

    Best Domain Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    if i want to add many sub domains, what shoud i do?
     
    Best Domain, Aug 17, 2007 IP
  14. Estevan

    Estevan Peon

    Messages:
    120
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    0
    #14
    hello

    to subdomain need wildcard dns enambled in server !

    httpd.conf and .htaccess only find files location !

    to enamble wildcard dns add * in CNAME in your domain db in /var/named
     
    Estevan, Aug 18, 2007 IP
  15. luka8088

    luka8088 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    hi, is this what you are looking for ?

    http://blog.luka8088.com/2009/06/16/mod_rewrite/
     
    luka8088, Jun 17, 2009 IP