Forum Moderators: phranque

Message Too Old, No Replies

Configuration Issue?

New Server, Standard Code Does Not Work.

         

jd01

3:15 am on Mar 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have used the following code on websites before to block access to php files for a direct request, but allow them for a sub-request. (I currently use it on a few.)

RewriteCond %{THE_REQUEST} \.php
RewriteRule \.php - [G]

I am just installed it on a different server and it appears the server is not recognizing the difference between a sub-request and an original.

Using the above generates a 'Gone' error every time a php page is internally requested, huh?

Could this be a configuration issue or does it have to be something silly I am missing?

Justin

coopster

9:20 pm on Mar 14, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What do you mean by internally requested? A PHP include() function? If so, are you using the http protocol for that include request?

jd01

9:34 pm on Mar 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



By 'internally requested' I mean rewritten...

RewriteCond %{THE_REQUEST} \.php
RewriteRule \.php - [G]

RewriteRule ^Sitemap$ /htm-files/sitemap.php [L]
RewriteRule ^Contact$ /htm-files/contact.php [L]

I use this series of code on other servers often.

The original request (%{THE_REQUEST}) should be for:
http://www.example.com/Sitemap

The secondary request (!%{THE_REQUEST}) should be for:
http://www.example.com/htm-files/sitemap.php

Justin

jdMorgan

3:55 am on Mar 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to check the 'action' on your site with a server headers checker. THE_REQUEST is just that: The original HTTP request line exactly as received from the client; It is unaffected by internal rewrites.

However, if another rule or a script generates an external redirect, then that will be a new HTTP request.

But since you've got this running on other servers, I'm thinking there might be a proxy involved -- That your requests to "your" server are actually proxied to one of a number of back-end servers, and there's something not quite right about that proxy setup, which should be invisible to you... Just a guess.

Jim

jd01

4:52 am on Mar 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks.

I appreciate the help from both of you.

It seems a bit odd, so I am guessing jdMorgan is on to something... This is on a new host (to me), so hopefully I can get it resolved.

I disallowed the directories the files are coming from to prevent duplication, but would like to get it worked out so it functions properly.

Justin