.Htaccess Rewrite Problem

Discussion in 'Apache' started by testman, Jun 5, 2006.

  1. #1
    I have a website that is located in a subdirectory of my hosting. ie. public_html/mysite/

    And I've got this set of code to make http://mysite.com point to the subdirectory:

    
    RewriteCond %{HTTP_HOST} mysite.com
    RewriteCond %{REQUEST_URI} !mysite/
    RewriteRule ^(.*)$ mysite/$1 [L]
    
    Code (markup):
    This works fine, but you can still visit the website by going here: http://mysite.com/mysite/
    Or visiting my forum like this: http://mysite.com/mysite/forum/

    Is there some way to detect the redundant /mysite and rewrite the url to exclude it? I tried for a couple hours, but I couldn't detect it. Here was my best guess:

    
    RewriteCond %{HTTP_HOST} mysite.com
    RewriteCond %{REQUEST_URI} ^/mysite/
    RewriteRule ^/mysite/(.*) http://mysite.com/$1 [R=301,L]
    
    Code (markup):
    Any help would be great, thanks.
     
    testman, Jun 5, 2006 IP