Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder Jazzo's Avatar
    Join Date
    Apr 2008
    Location
    New York City
    Posts
    164
    Thanks
    20
    Thanked 2 Times in 2 Posts

    Subdomain Redirect WWW

    I'm trying to set up a subdomain to redirect to a directory. I'm also trying to make it so that it will redirect www. I have this:
    Code:
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} ^www\.(.+)$
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    
    RewriteCond %{HTTP_HOST} subdomain.domain.com
    RewriteRule ^(.*)$ directory/$1 [L]
    but it's not working. It get a 500 Internal Server error for subdomain.domain.com and www.subdomain.domain.com is not found. Any help is appreciated.

    Thanks,
    Julian
    Last edited by Jazzo; 09-11-2010 at 01:13 AM.
    ~Julian
    14 y/o web developer, drummer, and Bridge player

  • #2
    Regular Coder Jazzo's Avatar
    Join Date
    Apr 2008
    Location
    New York City
    Posts
    164
    Thanks
    20
    Thanked 2 Times in 2 Posts
    Update: I messed around with it, and now, no matter what, subdomain.domain.com becomes an infinite redirect. I have no idea what's going on.
    ~Julian
    14 y/o web developer, drummer, and Bridge player

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    58
    Thanks
    2
    Thanked 6 Times in 6 Posts
    If I understand you correctly, you want something like code.google.com to redirect to google.com/code?

    Code:
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} ^code.google.com [nc]
    
    RewriteRule ^(.*)$ http://www.google.com/code/$1 [r=301,nc]
    I THINK that should work.


  •  

    Posting Permissions

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