Free Advertising - Free Advertising - Reptile Products - Credit Card - Debt Consolidation

PDA

View Full Version : .htaccess Re-Direct / Trailing Slash Problem in Sub Directory


zmsan
Feb 4th 2008, 6:41 pm
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>

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]

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!

norbert
Feb 5th 2008, 1:03 am
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]
and test again with domain.com/forums.

zmsan
Feb 5th 2008, 10:08 pm
I do not understand your solution? the file does not exist! Sorry to be so simple-minded. Could you expand perhaps?

norbert
Feb 6th 2008, 12:43 am
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.)