Twinkle Pandagre
Twinkle Pandagre

Reputation: 11

Return Https Status Code 410 Error for all Website Pages

I want to return 410 errors from my whole website pages so how to do this in just a few lines of code. I have used this syntax Redirect 410 [page-path] in .htaccess file but it is just to block one page what if I want for the whole website?

In doing so I think I have type this syntax 100 times. So is there any code that can help me to return 410 errors for the whole website.

Upvotes: 1

Views: 1141

Answers (1)

Stephen Ostermiller
Stephen Ostermiller

Reputation: 25524

You can use a pattern to match any URL on your site. Such a pattern is the regular expression .*. . means "any character" and * means "zero or more of them", so .* means "anything or nothing."

There are at least two different apache modules that can do this for you. You can usually choose to use either of them. The code would work either in your virtual host conf file or in a .htaccess file.

Using mod_alias:

RedirectMatch gone .*

RedirectMatch documentation

Using mod_rewrite:

RewriteEngine on
RewriteRule .* - [G]

Rewrite gone documentation

Upvotes: 0

Related Questions