need .htaccess help

Discussion in 'Programming' started by klown, Dec 13, 2006.

  1. #1
    Ok heres what i need to do. I have a server which has 10 domains on it. I want each of the subdomains to have their own folder which has its own word press installed.

    so i think i need to set my main root .htaccess (which is shared by all the add on domains) to redirect users to the correct subfolder.

    When they arrive there they should still be on the domain they requested, and be presented with word press. Also the internal mod rewrites of word press should be working too.

    After googling for it i found
    
    RewriteCond %{HTTP_HOST} ^www\.abc\.com
    RewriteCond %{REQUEST_URI} !/abc/
    RewriteRule (.*) /abc/$1 [L] 
    
    Code (markup):
    this results in a 500 Internal Server Error
     
    klown, Dec 13, 2006 IP
  2. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #2
    Which server are you using apache ?
    If yes you can try this


    .htaccess
    RewriteEngine On

    This activates Apache's URL rewriting engine. Follow this line with rulesets like the one below:

    RewriteCond %{HTTP_HOST} site1.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/vhosts/site1/.*$
    RewriteRule ^(.*)$ /vhosts/site1/$1 [L]

    RewriteCond %{HTTP_HOST} site2.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/vhosts/site2/.*$
    RewriteRule ^(.*)$ /vhosts/site2/$1 [L]

    site1.com will go to /vhosts/site1 ,etc
     
    it career, Dec 13, 2006 IP
  3. klown

    klown Peon

    Messages:
    2,093
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I still get a server 500 internal error. Maybe my server disallows doing this. I've got a pretty full cpanel not sure if i can do anything in there.
     
    klown, Dec 13, 2006 IP
  4. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #4
    Can you please check your server log , it can throw more light on this
    What is your websites url ?
     
    it career, Dec 13, 2006 IP
  5. klown

    klown Peon

    Messages:
    2,093
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Address is china-medical-insurance dot com

    the folder is the same, basically its at health-insurance-overseas dot com / china-medical-insurance

    log info, these are two errors, one (the latter) is from the code i tried at first and is in my first post, the other is from the code you posted.

    [Thu Dec 14 00:40:14 2006] [alert] [client 58.33.145.215] /home/healthi1/public_html/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps mis-spelled or defined by a module not included in the server configuration
    [Thu Dec 14 00:13:42 2006] [alert] [client 58.33.145.215] /home/healthi1/public_html/.htaccess: Invalid command '\xef\xbb\xbfRewriteCond', perhaps mis-spelled or defined by a module not included in the server configuration
     
    klown, Dec 14, 2006 IP
  6. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #6
    Rewrite*** commands are not interpreted at all, is their extra space/tab in your .htaccess files?

    what is the permission for .htaccess ?

    I think you need to ask for support from your hosting provider
     
    it career, Dec 14, 2006 IP
  7. technoguy

    technoguy Notable Member

    Messages:
    4,369
    Likes Received:
    306
    Best Answers:
    0
    Trophy Points:
    205
    #7
    try this in your htaccess file

    .htaccess
    RewriteEngine On

    This activates Apache's URL rewriting engine. Follow this line with rulesets like the one below:
     
    technoguy, Dec 14, 2006 IP
  8. klown

    klown Peon

    Messages:
    2,093
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #8
    ok still getting a 500 internal error. the exact code i'm using in the .htaccess is below
    .htaccess
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} china-medical-insurance.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/china-medical-insurance/.*$
    RewriteRule ^(.*)$ /china-medical-insurance/$1 [L]
    Code (markup):
     
    klown, Dec 14, 2006 IP
  9. klown

    klown Peon

    Messages:
    2,093
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Ok that doesn't seem to be working, how about this. Can I use mod rewrite to chop off a subfolder?

    So the blog would actually be located at http://www.china-medical-insurance.com/china-medical-insurance/

    however the rewrite would change that to be
    http://www.china-medical-insurance.com
     
    klown, Dec 17, 2006 IP
  10. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #10
    Is that really the exact code :

    
    RewriteEngine On
    RewriteCond %{HTTP_HOST} china-medical-insurance.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/china-medical-insurance/.*$
    RewriteRule ^(.*)$ /china-medical-insurance/$1 [L]
    
    Code (markup):
    remove ".htaccess" from it ......
     
    krakjoe, Dec 18, 2006 IP