Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-19-2012, 11:36 PM   PM User | #1
helenp
New Coder

 
Join Date: Oct 2011
Posts: 65
Thanks: 1
Thanked 0 Times in 0 Posts
helenp is an unknown quantity at this point
rewrite htm as php gives 400 error?

Hi, been seing several times this in my error log
[Thu Jan 19 16:19:32 2012] [error] [client 176.31.104.41] File does not exist: /home/mysite/public_html/index.php, referer: http://www.marbellasunrentals.com/index.php

I have a rewriterule in my htaccess that tells the server to treat html as php pages.
So I have my index.htm with a link to home that is on all pages, and its called index.htm not index.php
So I dont understand this error, it says index.php does not exists wich is true but the referres is myste/index.php

Can anybody explain this please.
Thanks

Last edited by helenp; 01-20-2012 at 01:49 PM..
helenp is offline   Reply With Quote
Old 01-20-2012, 07:41 AM   PM User | #2
leslie.jones
New Coder

 
Join Date: Nov 2011
Posts: 88
Thanks: 4
Thanked 26 Times in 26 Posts
leslie.jones is an unknown quantity at this point
If the file does not exists - and you agree that it does not - then that log line is correct.....
BUT...
From the outside you appear to have an index.php file which is serving up a meta refresh to hop to index.htm:
<meta http-equiv="Refresh" content="5; URL=index.htm">
[guessing an internal redirect going on here]

Requesting: http://www.marbellasunrentals.com/index.php generates a 404 but this is caught and handled so I'm guessing you have a rewrite rule that is catching 404's and redirecting them. (in between there is a refer to toolbarqueries.google.com which gives a 403 forbidden but no on page error is generated). That may explain why the file index.php does not exist, but the referrer would be correct in essence if the redirect is internal.

It would help if you could share your rewrite rule(s) to be more specific.

Last edited by leslie.jones; 01-20-2012 at 07:51 AM..
leslie.jones is offline   Reply With Quote
Old 01-20-2012, 08:07 AM   PM User | #3
helenp
New Coder

 
Join Date: Oct 2011
Posts: 65
Thanks: 1
Thanked 0 Times in 0 Posts
helenp is an unknown quantity at this point
Quote:
Originally Posted by leslie.jones View Post
If the file does not exists - and you agree that it does not - then that log line is correct.....
BUT...
From the outside you appear to have an index.php file which is serving up a meta refresh to hop to index.htm:
<meta http-equiv="Refresh" content="5; URL=index.htm">
[guessing an internal redirect going on here]

Requesting: http://www.marbellasunrentals.com/index.php generates a 404 but this is caught and handled so I'm guessing you have a rewrite rule that is catching 404's and redirecting them. (in between there is a refer to toolbarqueries.google.com which gives a 403 forbidden but no on page error is generated). That may explain why the file index.php does not exist, but the referrer would be correct in essence if the redirect is internal.

It would help if you could share your rewrite rule(s) to be more specific.
Thanks, but I dont have any index.php file with a meta refresh to a htm
I have a index.htm file wich have a rewriterule in htaccess for the server to serve as php as there are php code in it and I didnt want to change extension.
The metarefresh you see is from my 404 errorpage that redirects all 404 to index.htm

What I dont understand is the referer index.php as this does not exists, also there are no link on the web as far as I know to any index.php page.

This I did not understand:
(in between there is a refer to toolbarqueries.google.com which gives a 403 forbidden but no on page error is generated).
I have google analytics if this is what you mean???????


Sorry it was not a rewriterule but an addextension, did not remember, this is from my .htaccess:
AddType application/x-httpd-php5 .htm .html
RewriteEngine On
RewriteCond %{HTTP_HOST} ^marbellasunrentals\.com
RewriteRule (.*) http://www.marbellasunrentals.com/$1 [R=301,L]
helenp is offline   Reply With Quote
Old 01-20-2012, 12:06 PM   PM User | #4
leslie.jones
New Coder

 
Join Date: Nov 2011
Posts: 88
Thanks: 4
Thanked 26 Times in 26 Posts
leslie.jones is an unknown quantity at this point
Smile

Quote:
Originally Posted by helenp View Post
What I dont understand is the referer index.php as this does not exists, also there are no link on the web as far as I know to any index.php page.
Ah, I understand.

If you take a look at the request and responses to your service with something like the Firefox add-in HTTP Live Headers, you'll see the 404 and other bits and pieces going on. Initially I thought I had a browser helper doing an auto search and correcting the request when the 404 came back, but when I could get Lynx to do it to, I figured you must have a custom 404 handler on that server that is issuing a meta-refresh to index.htm

If you trace the request in Lynx you get:
[command: lynx -trace -tlog http://www.marbellasunrentals.com/index.php]
Code:
GET /index.php HTTP/1.0\r
Host: www.marbellasunrentals.com\r
Accept: text/html, text/plain, text/css, text/sgml, */*;q=0.01\r
Accept-Encoding: gzip, compress, bzip2\r
Accept-Language: en\r
User-Agent: Lynx/2.8.8dev.2 libwww-FM/2.14 SSL-MM/1.4.1\r
\r
----------------------------------
Sending HTTP request.
HTTP: WRITE delivered OK
HTTP request sent; waiting for response.
HTTP: Trying to read 1535
HTTP: Read 1420
HTTP: Rx: HTTP/1.1 404 Not Found 
HTTP: Scanned 2 fields from line_buffer
--- Talking HTTP1.

Alert!: HTTP/1.1 404 Not Found
The 404 error page contains this line:
Code:
<meta http-equiv="Refresh" content="5; URL=index.htm">
Which bounces any page not found (404) to index.htm. Naturally this will catch a request for index.php

This will mean your logs correctly show both file not found (for index.php error code 404), and preserves the original requested URI (index.php) passing it through as the referrer - which I guess you could argue it kinda technically is.

Something much cruder that just shows the 404 error, without redirecting:
Code:
wget http://www.marbellasunrentals.com/index.php
--2012-01-20 11:40:52--  http://www.marbellasunrentals.com/index.php
Resolving www.marbellasunrentals.com... 68.71.137.3
Connecting to www.marbellasunrentals.com|68.71.137.3|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2012-01-20 11:40:52 ERROR 404: Not Found.
Hope that sounds plausible - take a look at your 404 handler page, it's not the vanilla Apache offering and is customised with that meta refresh by the look of it :-) A request for index.jsp, index.asp or index.any_old_thing_that_does_not_exists will do the same thing :-)

Last edited by leslie.jones; 01-20-2012 at 12:11 PM..
leslie.jones is offline   Reply With Quote
Old 01-20-2012, 01:44 PM   PM User | #5
helenp
New Coder

 
Join Date: Oct 2011
Posts: 65
Thanks: 1
Thanked 0 Times in 0 Posts
helenp is an unknown quantity at this point
Thanks,
Sorry but still dont understand:
The site is 10 years old as as far as I know there arent any link with index.php
Anyway you said:
"Which bounces any page not found (404) to index.htm. Naturally this will catch a request for index.php"
why would it catch a request for index.php when its redirected to index.htm
I have often 404 error as I do delete pages and ever seen that.
These are pages that dont exists anymore and I have this in errorlog:

[Fri Jan 20 02:48:43 2012] [error] [client 208.115.111.68] File does not exist: /home/mysite/public_html/espanol/z1masfotos_banana_beach_bw.htm
[Fri Jan 20 02:48:40 2012] [error] [client 208.115.111.68] File does not exist: /home/mysite/public_html/z1morephotos_casa_blanca_4.htm
[Fri Jan 20 02:44:30 2012] [error] [client 69.171.229.249] File does not exist: /home/mysite/public_html/photos
they are taken to index.htm same as index.php are.

Also the end,
"Something much cruder that just shows the 404 error, without redirecting:
continue....."

I dont understand what you mean either.
Isnt the 404 error page correct?

Added, just did a test and tried to enter index.php
and got this error in errorlog, no referer at all:
[Fri Jan 20 06:45:09 2012] [error] [client 80.174.72.31] File does not exist: /home/mysite/public_html/index.php
This looks normal to me, the other one does not

Last edited by helenp; 01-20-2012 at 01:48 PM..
helenp is offline   Reply With Quote
Old 01-20-2012, 04:05 PM   PM User | #6
leslie.jones
New Coder

 
Join Date: Nov 2011
Posts: 88
Thanks: 4
Thanked 26 Times in 26 Posts
leslie.jones is an unknown quantity at this point
Quote:
Originally Posted by helenp View Post
Thanks,

[Fri Jan 20 02:48:43 2012] [error] [client 208.115.111.68] File does not exist: /home/mysite/public_html/espanol/z1masfotos_banana_beach_bw.htm
[Fri Jan 20 02:48:40 2012] [error] [client 208.115.111.68] File does not exist: /home/mysite/public_html/z1morephotos_casa_blanca_4.htm
[Fri Jan 20 02:44:30 2012] [error] [client 69.171.229.249] File does not exist: /home/mysite/public_html/photos
they are taken to index.htm same as index.php are.
You have, somewhere, set up a custom 404 error page that directs ANY request for a non existent file to index.htm. Here it is:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Page not found</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="http://www.marbellasunrentals.com/css/nuevotest7.css">
<meta http-equiv="Refresh" content="5; URL=index.htm">
</head>
<body>
<div id="container">
<div id="title"><a class="title" href="index.htm">Marbella Sun Rentals</a></div>
  <div id="content1">
  <div class="texto">
    <p>&nbsp;</p>
    <p><a href="http://www.marbellasunrentals.com"><img src="http://www.marbellasunrentals.com/images/bandera_inglesa_.gif" alt="Web in english" width="25" height="16" border="0"></a> 
      Sorry, this page was not found. In a few seconds, you will be redirected 
      to our main page. If you aren&acute;t redirected automatically, just make 
      clic on the flag of language of your choise.</p>
    <p><a href="http://www.marbellasunrentals.com/espanol/"><img src="http://www.marbellasunrentals.com/images/bandera_espanola_.gif" alt="web en espanol" width="25" height="17" border="0"></a> 
      Lo sentimos, esa p&aacute;gina no existe, en unos segundos ser&aacute; redireccionado
       a nuestra p&aacute;gina principal. Si no fuera redireccionado autom&aacute;ticamente,
        solamente haga clic en bandera de su idioma preferido.</p>
    <p><a href="http://www.marbellasunrentals.com/svenska/"><img src="http://www.marbellasunrentals.com/images/bandera_sueca_.gif" alt="web pa svenska" width="25" height="16" border="0"></a> 
      Den h&auml;r sidan kunde inte hittas, om en liten stund kommer du att flyttas 
      till v&aring;r startsida. Om du inte flyttas automatiskt, klicka 
      p&aring; ditt spr&aring;ks flagga.</p>
    </div>
  </div>
</div>
</body>
</html>
People (hackers, general nerds, search engines etc) will try index.php regardless of if you have links to it or not - such noise in apache logs is common.

Your specific 404 handler means requests for absolutely anything that should fire off a '404 page not found' will redirect to index.htm after five seconds because of the meta-refresh in your custom 404 page.
leslie.jones is offline   Reply With Quote
Reply

Bookmarks

Tags
rewriterule error 400

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:38 PM.


Advertisement
Log in to turn off these ads.