bikeman
Joined: Feb 13, 2005
# Posts: 130
|
Posted: 2006-Dec-07 09:36
I am getting a 302 and then a 404 from my error page (see below)
#1 Server Response: http://www.domain/website_design/dada.htm
HTTP Status Code: HTTP/1.1 302 Found
Date: Thu, 07 Dec 2006 08:27:39 GMT
Server: Apache/1.3.33 (Unix)
Location: [link]
Connection: close
Content-Type: text/html; charset=iso-8859-1
Redirect Target: http://www.domain/error404.php
#2 Server Response: http://www.domain/error404.php
HTTP Status Code: HTTP/1.1 404
Date: Thu, 07 Dec 2006 08:27:39 GMT
Server: Apache/1.3.33 (Unix)
X-Powered-By: PHP/5.1.6
Connection: close
Content-Type: text/html
I have a .htaccess in the directory with
ErrorDocument 404 /error404.php
And the following in the error404.php page
<?php
header("HTTP/1.0 404 Not Found" ;
?>
Can someone advise what I am doing wrong
Thanks
[ Message was edited by: bhartzer 12/19/2006 06:20 am ]
|
 |
Prowler
Staff
Joined: Aug 14, 2000
# Posts: 1832
|
Posted: 2006-Dec-09 05:07
First thought is there is an overriding directive upstream of the directory which does the 302. Test this out in a new directory (created for this purpose).
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10465
|
Posted: 2006-Dec-09 21:02
There are several situations where this can occur.
Check the Apache Manual carefully for some common reasons.
|
 |
bikeman
Joined: Feb 13, 2005
# Posts: 130
|
Posted: 2006-Dec-10 10:03
Problem happens in all directories.
'Apache manual'? I use 1and1 shared hosting so server settings mean nothing to me.
Any suggestions as to what I should ask 1and1?
|
 |
Prowler
Staff
Joined: Aug 14, 2000
# Posts: 1832
|
Posted: 2006-Dec-11 14:29
Ok. I checked out your site and your error404.php page is firing correctly as it should without any 302 if you request a non-existent file from the root. But it triggers the 302 only inside the website_design/ directory. There must be some directive in this directory. Check this directory's .htaccess file.
|
 |
bikeman
Joined: Feb 13, 2005
# Posts: 130
|
Posted: 2006-Dec-17 10:39
Hi Prowler
You're right about the difference between root and subdirectories but the .htaccess on the root is
ErrorDocument 400 /error404.php
ErrorDocument 403 /error404.php
ErrorDocument 404 /error404.php
ErrorDocument 500 /error404.php
and the .htaccess in the sub-directory is
ErrorDocument 400 hxxp://xxx.lamtha2.co.uk/error404.php
ErrorDocument 403 hxxp://xxx.lamtha2.co.uk/error404.php
ErrorDocument 404 hxxp://xxx.lamtha2.co.uk/error404.php
ErrorDocument 500 hxxp://xxx.lamtha2.co.uk/error404.php
(note x substituted for t and w)
I can't see anything wrong with this.
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10465
|
Posted: 2006-Dec-17 20:45
In the Apache Manual that I referred to earlier it states, in the section about "common problems", that including the domain name in the URL will trigger a 302 response instead of the intended 404 code. The remedy is to not include the domain name in the URL for where the error file is located.
|
 |
Prowler
Staff
Joined: Aug 14, 2000
# Posts: 1832
|
Posted: 2006-Dec-18 04:23
g1smd is correct. Don't issue complete URL in the sub-directory. Issue relative path URL and it should work.
|
 |
bikeman
Joined: Feb 13, 2005
# Posts: 130
|
Posted: 2006-Dec-18 15:38
I also read somewhere that with apache the url must be relative to the root BUT then the 404error.php page is picked up without any images or css layout.
So I have to use an absolute url to get the error.phppage to display correctly.
I have changed .htaccess to a root relative url so you can see what I mean
|
 |
Hampstead
Joined: Feb 20, 2001
# Posts: 2061
|
Posted: 2006-Dec-19 12:56
Place a copy of the images in the route too and they should display OK
|
 |
bikeman
Joined: Feb 13, 2005
# Posts: 130
|
Posted: 2006-Dec-19 14:05
I don't think much of that suggestion and it doesn't work anyway!
The images are in a sub-directory called images - not unreasonable
|
 |
Prowler
Staff
Joined: Aug 14, 2000
# Posts: 1832
|
Posted: 2006-Dec-20 04:08
If images and CSS located in a directory downstream are the problem, it is not an issue. Set the path to them in the error404.php like so:
The above statement assumes that the image is located one level down beneath the document root.
|
 |
bikeman
Joined: Feb 13, 2005
# Posts: 130
|
Posted: 2006-Dec-20 14:40
oh dear this is going round in circles...
The css files are in the root directory
The image paths are already <img src="../image/some_image.jpg" width="xx" height="xx">
The error404.php shows perfectly when browsed to directly
But not when called from the .htaccess
|
 |
Hampstead
Joined: Feb 20, 2001
# Posts: 2061
|
Posted: 2006-Dec-20 16:25
Have you followed G1SMD's advice yet?
Did it work?
|
 |
bikeman
Joined: Feb 13, 2005
# Posts: 130
|
Posted: 2006-Dec-21 08:19
on 12/18 I said
I have changed .htaccess to a root relative url so you can see what I mean
|
 |
Hampstead
Joined: Feb 20, 2001
# Posts: 2061
|
Posted: 2006-Dec-21 09:01
Is it the site in your profile?
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10465
|
Posted: 2006-Dec-21 14:32
Call both the CSS and the images with a URL that begins with a / and hence specifies the full, but local, path to the file.
Make sure the page also has a noindex tag on it. It's all in that manual I referred to.
|
 |
Prowler
Staff
Joined: Aug 14, 2000
# Posts: 1832
|
Posted: 2006-Dec-22 04:28
It appears from your 404 page that some images are 'broken'. The browser is looking for www.your-domain/website_design/images/CIW_MasterCIWDesigner.gif and it doesn't exist there.
You can easily resolve the path issue by checking for the image placeholder in the browser and see where it points to. Once you see where it is looking at, you can modify the path to reflect it.
Again I see that error404.php is not the one served for a non-existent file indicating that you have set up a new file.
|
 |
bikeman
Joined: Feb 13, 2005
# Posts: 130
|
Posted: 2006-Dec-22 09:37
Prowler, I think you are being misled by the url you see in the browser window when you say quote "Again I see that error404.php is not the one served for a non-existent file indicating that you have set up a new file".
I haven't setup any new files - There IS ONLY ONE error file. It is at www.domain/error404.php
The url shows whatever you type in - garbage in/garbage out -so you type in www.domain.co.uk/dsghadj.html that;s what you see yet www.domain/error404.php is displayed.
Error404.php DISPLAYS CORRECTLY when called directly or when called by a non-existent file in the root directory.
BUT it doesn't display correctly when called via .htaccess for a non-existant file in a sub-directory.
All image paths are:
<img src="images/some_image.jpg" width="xx" height="xx">
But I have tried the suggested alternative image paths eg
<img src="../images/some_image.jpg" width="xx" height="xx">
or
<img src="/images/some_image.jpg" width="xx" height="xx">
or
<img src="images/some_image.jpg" width="xx" height="xx">
and none of them work.
The only method that works is to use an absolute url BUT then the server returns a 302!
I don't think my issue is with the image paths - more with the way the .htaccess is diverting to the error404.php page. It seems to pick up the correct page but expect the images to be in what ever sub-directory was originally called!
|
 |
Prowler
Staff
Joined: Aug 14, 2000
# Posts: 1832
|
Posted: 2006-Dec-23 05:25
I use a Linux Box with a Mozilla Firefox to test out your websites alongside a Windows box with a standard IE 6.0 bikeman. In both the cases I tried for a file named 'bingo' from your website_design directory and they returned what looks like a different page from the actual error404.php .
Be that as it may, there is a n easy way out to solve your path problem - use this absolute URL to call any images and css files like the one provided below:
Many people use this technique of direct complete URL to locate the required files when many sections of the page are created/maintained by different teams.
|
 |