Paul Paul - 1 month ago 9
PHP Question

htaccess redirect everything to 410

I am trying to force all requested urls from a domain to a custom 410 error page. I am using the following rule, but it does not catch everything. I need it to catch all folders, .html, .php and jpgs etc...

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^index\.html$ index.html [L,R=410]

ErrorDocument 410 /error-410.php


Can anyone help? Cheers

Answer

Try this in your root .htaccess:

ErrorDocument 410 /error-410.php

RewriteEngine on

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?sub\.domain\.com$ [NC]
RewriteRule ^ - [L,R=410]