Forum Moderators: phranque
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
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?
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]
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.
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.
If not, then test with something simple like this:
Options +FollowSymLinks -MultiViews
RewriteEngine on
#
RewriteRule ^foo\.html$ http://www.google.com [R=301,L]
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]
RewriteRule ^filename\.html$ - [G]
[webmasterworld.com...]
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]
[httpd.apache.org...]
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]
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"
Or maybe a search [google.com] would be easier.
Jim
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.
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