Mobile app version of vmapp.org
Login or Join
Welton855

: How can I redirect everything but the index as 410? Our site shut down and we need to give a 410 redirect to the users. We have a small one-page replacement site set up in the same domain

@Welton855

Posted in: #410Gone #Apache #Htaccess #ModRewrite #Redirects

Our site shut down and we need to give a 410 redirect to the users. We have a small one-page replacement site set up in the same domain and a custom 410 error page. We'd like to have it so that all page views are responded with 410 and redirected to the error page, except for the front page, which should point to the new index.html.

Here's what in the .htaccess:

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


This works, except for one thing: If I type the domain name, I get the 410 page.

With example.com/index.html I see the index page as I should, but just example.com gets 410. How could I fix this?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Welton855

2 Comments

Sorted by latest first Latest Oldest Best

 

@Sent6035632

If I follow what you're trying to do, I think this would work.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* - [L,G]


If the resource doesn't exist (is not either a file or a directory) send the 410.

10% popularity Vote Up Vote Down


 

@Kristi941

Create a page called maintenance.html (or whatever file extension necessary for your server side language of choice) and then use this code:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=410,L]
</IfModule>


This will always show maintenance.html regardless of which page they request in their browser.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme