Apache 410 Gone instructions not working with mod_alias nor mod_rewrite

apache-2.2mod-aliasmod-rewrite

Apache 2.2 (on a server running cPanel) seems to be ignoring instructions to return a 410 status.

This happens for both mod_alias's Redirect (using 410 or gone) and mod_rewrite's RewriteRule (using [G]), being used inside a .htaccess file.

This works:

Redirect 302 /somewhere /gone

But this doesn't:

Redirect 410 /somewhere

That line is ignored (as if it had been commented) and the request falls through to other rules (which direct it to an unrelated generic error handling script).

Similarly, trying to use a RewriteRule with a [G] flag doesn't work, but the same rule rewriting to a script that generates a 410 does – so the rules aren't the problem and it seems instead to be something about 410/gone that isn't behaving.

I can workaround it by having a script sending the 410, but that's annoying and I don't get why it's not working.

Any ideas?

Best Answer

There appears to be a bug in cPanel - it requires an explicit ErrorDocument for the 410 to take effect.

So, the solution is to add the following to the .htaccess:

ErrorDocument 410 default

This then enables the [G] to work for RewriteRule. (Have not yet verifited that Redirect is fixed also.)

Source: http://wordpress.org/support/topic/410-errors-returning-404-pages

Related Topic