Forum Moderators: phranque

Message Too Old, No Replies

Setting up a 410 error page

not working

         

Lorel

2:33 pm on Jan 21, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have htaccess set up and working for 404 error and it goes to my own 404 error page. I tried to do the same with my own 410 error page and it reverts to the 404 (it works fine witout my own page but want the error pages to all look the same).

Is there something wrong with my code?

I have expired pages set up on htaccess like this:

RewriteRule ^filename\.html - [G]

Here is the error codes in the htaccess file:

ErrorDocument 404 /missing.html
ErrorDocument 410 /missing410.html
#AddHandler server-parsed .html

jdMorgan

3:05 pm on Jan 21, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you completely flush your browser cache before testing?

Jim

Lorel

6:33 pm on Jan 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I dumped the browser cache and tried another browser and it still doesn't work.

I also just tried setting up a 410 error on another site for a directory whose contents have been removed (as well as the whole directory) using the following and this doesn't work either. It's bring up the 404 error page (I used the same set up as above)

RewriteRule ^photos/ - [G]

Can anyone see what I'm doing wrong?

jdMorgan

11:02 pm on Jan 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't see that you're doing anything wrong... Maybe your host has not granted you AllowOverride FileInfo and Options privileges? (See Apache core AllowOverride directive)

Jim

Lorel

3:39 pm on Jan 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi Jim,

I called the host and he said the server is configured correctly and that it's picking up the 404 error page because the 410 doesn't show up in the browser, although it is registering as a 410 and so it displays the 404 error page (which is btw, all messed up -- not picking up the SSI or CSS).

Does this sound like normal practice for a 410 error?

PS. when I check the url in a http checker it shows it as a 404.

I have other clients on the same host and the 410 brings up a generic 410 error page but not on this site.

[edited by: Lorel at 3:41 pm (utc) on Jan. 29, 2008]

lammert

5:16 pm on Jan 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Does this sound like normal practice for a 410 error?

No, this is not normal behaviour. You should receive the 410 gone page, both when checking with a browser and with a server header checker.

The only thing I can think of is that the errordocument you specified for the 410 error doesn't exist. In that case the 410 error will generate a 404 error which is returned to the browser.

Lorel

1:30 am on Jan 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Actually the 410 as specified in my first post above does exist.

I took out the parse code for the 410 just to see if the rewrite for "gone" will bring up the generic error page and it brings up the 404 instead.

I'll call tech support soon and try and get someone else who may know what they are doing.

thanks for trying to help.

jdMorgan

2:06 am on Jan 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Taking a step back from this, do you have any other working rewriterules? Have you included the
Options and RewriteEngine directives required by mod_rewrite?

If not, then test with something simple like this:


Options +FollowSymLinks -MultiViews
RewriteEngine on
#
RewriteRule ^foo\.html$ http://www.google.com [R=301,L]

Jim

Lorel

8:15 pm on Jan 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi Jim,

I have about 20 other clients on the same host including my own site and a 410 error always results in a generic 410 error page. Not for the directory for this client that I've removed below, however.

Here is the whole htacess file (I deleted the missing410.html page)

Let me know if I should still includel the code you posted above.

------

ErrorDocument 404 /missing.html
AddHandler server-parsed .html

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.org
RewriteRule ^(.*)$ http://www.example.org/$1 [R=301,L]
RewriteRule ^photos/ - [G]

jdMorgan

5:23 am on Feb 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I really don't know. There is nothing apparently wrong with your code, and the only dependency I see is the parsing of html for php. But even that dependency shouldn't affect serving the default 410 error page.

Time to pound your shoe on the help desk, I'm afraid...

Jim

Marcia

5:59 am on Feb 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It starts with the ^ but where does the path for the directive end? How about this way?

RewriteRule ^filename\.html$ - [G]

[webmasterworld.com...]

Marcia

7:34 am on Feb 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, I've just tried this on two different hosts (diff servers), and this would not work with separate error documents for 404 and 410, both with and without the "dollar sign."

ErrorDocument 404 /foo.html
ErrorDocument 410 /gone410.html

I ran a 404 page and a 410 page through a header checker, and they both return 404 and 410 correctly. BUT separate custom pages won't work for the 410, it gives a default "page gone" rather than the custom one.

They're both working fine using the same ErrorDocument for both, and in both cases return the right header code.

Added for clarity:

ErrorDocument 404 /foo.html
ErrorDocument 410 /foo.html

They both bring up the custom page, which returns 404 and 410 just as they should (even though it's the same ErrorDocument used for both).

[edited by: Marcia at 7:54 am (utc) on Feb. 1, 2008]

jdMorgan

6:25 pm on Feb 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have never seen anything like this before.

Just a thought, are MultiViews enabled on this server? Have you tried disabling them?

Jim

coopster

6:48 pm on Feb 1, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Make sure there are no variant (typically set up as *.var) files set up either if mod_negotiation is enabled. One last thing, do you know which server version is running? If it is Apache 2.2 ... see if you can get them to restart the server.

[httpd.apache.org...]

Marcia

11:32 pm on Feb 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've got it this way on 5 accounts with 3 different hosts, all Apache 1.3 (and all Cpanel). There are a couple of other places hosted also, now that this has come up I'll check those out, too. Is it possible that it's something to do with Cpanel?

Added:
Just checked and even though doing redirects to custom error documents "by hand," this is what's available through Cpanel's custom redirect capability: 400, 401, 403, 404, 500. No 410 listed, so it may just be a Cpanel thing. The 410 works, but a separate page for it doesn't.

[edited by: Marcia at 11:41 pm (utc) on Feb. 1, 2008]

Lorel

11:29 pm on Feb 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just a thought- both these sites are on Apache 2.x

would that have anything to do with the problem?

jdMorgan

12:22 am on Feb 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Possibly. See AcceptPathInfo in Apache core docs.

Jim

Lorel

4:19 pm on Feb 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Update.

The first site I was having a problem with corrected itself without my doing anything so either I had a typo somewhere or the host fixed a bug without my knowing.

The 2nd site I was having a problem with (on a different host but both on Apache2) I had a rewrite for a 410 for a folder that had been removed called "photos". I had set up a new page call photos.html when the site was redesigned and according to the tech person the rewrite got confused and and threw a 404 when it couldn't find the photos directory.

I renamed the photos page to widgetphotos.html and then the generic 410 worked.

However when I set up the custom 410 and added that to htaccess it is picking up the 404 error page, so it's still not working correctly as others have noticed. I reverted it back to the generic 410 page until this problem is solved.

BTW, I don't know how to find
"AcceptPathInfo in Apache core docs" or "Multiviews"

jdMorgan

5:31 pm on Feb 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



On the Apache Web site, HTTP Server Apache 2.0 documentation section, in the Modules subsection, on the Core page:
AcceptPathInfo [httpd.apache.org]
Options [httpd.apache.org] (See MultiViews option)

Or maybe a search [google.com] would be easier.

Jim

Marcia

10:32 pm on Feb 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>BTW, I don't know how to find
"AcceptPathInfo in Apache core docs" or "Multiviews"

Do you even have access to see those on shared hosting?

jdMorgan

3:23 am on Feb 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Each Apache directive has a line in its documentation titled "Context:". In this case, the AcceptPathInfo and Options directives are available in the .htaccess context, unless the host has forbidden them by using "AllowOverride None" or individually restricting them by group.

Jim

Lorel

1:21 pm on Feb 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The tech person at my host had me add the following to the htaccess file:

Options -MultiViews

This brought up the custom 410 error page however I had to write in full URLs to the images on the page as they didn't display and I eventually took out the SSIs on the page also as full URLs wouldn't work on those. It's like the 410 page is coming from another folder when it's actually in the root. Can someone tell me why this happens? the 404 custom page displays correctly.

jdMorgan

1:45 pm on Feb 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is a common symptom of images and other 'includes' being called from an internally-rewritten URL. And a custom error document is essentially "rewritten-to" when an error occurs; If you cause an error and then look at the address bar while viewing your resulting custom error page, your should see the originally-requested (bad) URL. So any relative links within that custom error page will be resolved by the browser according to the URL that was originally requested, not the URL of the error page.

Therefore, you'll usually have to use server-relative or canonical URLs in your custom error documents.

Server-relative URL: <img src="/images/logo.gif">
Canonical URL: <img src="http://www.example.com/images/logo.gif">

If you are seeing some deviation from this behaviour, it's likely because your host is doing some additional internal rewriting or aliasing that they don't tell their customers about. It's not uncommon, and is the reason for the existence of (and need for) the RewriteBase directive in mod_rewrite.

Jim

Lorel

7:17 pm on Feb 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Ahhh. That explains it. Thanks for your help.