Forum Moderators: phranque

Message Too Old, No Replies

.htaccess question.

What in this rule is causing the weird behavior?

         

timothius

10:14 pm on Aug 6, 2008 (gmt 0)

10+ Year Member



Alright, here's my code:

# Enable mod_rewrite
Options +FollowSymlinks
RewriteEngine on
#
# Internally rewrite visitors referred by EXTERNAL-DOMAIN.COM to PAGE1.html page
RewriteCond %{HTTP_REFERER} EXTERNAL-DOMAIN\.com
RewriteCond %{REQUEST_URI} !^/PAGE1\.html$
RewriteRule .* /PAGE1.html [L]

Ok, so based on this rewrite rule, WHY when I visit a directory on my site that does exist (Example: www.mysite.com/directory1/), I always get redirected to www.mysite.com/PAGE1.html? Just so you know, the directory that I am requesting does not have an index page setup intentionally.

I don't have a clue as to why this is happening... I would have thought that since there is no index in the directory that is being requested, my site would give a 403 error? I don't want visitors being redirected to PAGE1.html unless they are coming from a *particular* domain as I have it setup to do above.

Thank-you so much!

jdMorgan

11:00 pm on Aug 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From what I can see, you've got two problems. First, the HTTP_REFERER test isn't working, apparently. But that doesn't make sense, unless the code here doesn't match what's on your server. So, I suspect a secondary problem.

Disable this rule and add "-Indexes" to your Options directive. Then request that non-existent directory index URL again. What ErrorDocument does the server serve as a result?

Be sure to completely-flush your browser cache before starting a new round of testing, and after changing the code in any way.

Jim

timothius

4:13 am on Aug 7, 2008 (gmt 0)

10+ Year Member



This is weird... I removed the rule and added changed the options line to:

Options +FollowSymlinks -Indexes

However, it still does the same thing. I don't have any other rewrite rules that have anything to do with PAGE1.html. (I only have 2 other rewrite rules in my .htaccess) I also don't have any other .htaccess files on my server.

Thanks!