.htaccess Re-Direct / Trailing Slash Problem in Sub Directory

Discussion in 'Apache' started by zmsan, Feb 4, 2008.

  1. #1
    Hello,

    My root .htaccess is as follows:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
    
    #for wordpress
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    Code (markup):
    My forums sub-directory is:
    
    <IfModule mod_security.c>
       SecFilterEngine Off
       SecFilterScanPOST Off
    </IfModule>
    Options +FollowSymlinks
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/forums/$1 [R=301,L]
    
    RewriteRule ^((urllist|sitemap).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_FILENAME} (admincp|modcp|clientscript|cpstyles|images)/
    RewriteRule ^(.*)$ $1 [L]
    
    RewriteCond %{QUERY_STRING} !vbseourl=
    RewriteCond %{REQUEST_FILENAME} !chat
    RewriteRule ^(.*\.php)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    
    RewriteRule ^(archive/.*)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    Code (markup):
    The problem only exists when I go to the following:

    domain.com/forums

    it re-directs to:

    http://www.domain.com/forums//home/user/public_html/forums

    It should go to:

    http://www.domain.com/forums/

    For example, I go to:

    http://www.domain.com/forums

    and it successfully re-directs to:

    http://www.domain.com/forums/

    This is DRIVING ME CRAZY!
     
    zmsan, Feb 4, 2008 IP
  2. norbert

    norbert Guest

    Messages:
    61
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This is really interesting. From just looking at the code I couldn't find the reason.
    To find out more, if possible, change $1 to something like testxyz.html in the forum subdir rules:
    RewriteRule ^(.*)$ http://www.domain.com/forums/testxyz.html [R=301,L]
    Code (markup):
    and test again with domain.com/forums.
     
    norbert, Feb 5, 2008 IP
  3. zmsan

    zmsan Active Member

    Messages:
    90
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #3
    I do not understand your solution? the file does not exist! Sorry to be so simple-minded. Could you expand perhaps?
     
    zmsan, Feb 5, 2008 IP
  4. norbert

    norbert Guest

    Messages:
    61
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    oh yes, the reason is that at this point I can only guess where the origin of the problem is.
    I assume it has to do with the rule I mentioned and that $1 is being replaced with
    "/home/u...ic_html/forums". If you replace $1 with something that doesn't exist or a file
    that does exist, no matter what, then there should be no replacement any more, it should
    be rewritten to the file. Just to isolate the problem and gain more information.
    The next step is to reduce the rules, e.g. disable the wordpress rules, then disable the forum
    rules below the rule I mentioned. (If you want contact me via ICQ to get this solved more quickly.)
     
    norbert, Feb 5, 2008 IP