I have seen many suggestions on various redirects, but none were simple and many had no accepted answer.
I have a site I wish to completely remove from google and have only my homepage available
In that homepage I have image css and js files so they of course should not be redirected
My plan was to redirect all .html and all .php that are not the /index.html in root to the /index.html in root
Of course / should also be allowed.
So /js, /css, /img and /images should be left alone
Any other php or html page I thought I wanted to have 301 to /index.html
This worked but as pointed out in a comment, does not tell Google that the content that it indexed is no longer supposed to be there
Stackoverflow: how-to-redirect-all-pages-only-to-index-html-using-htaccess-file-and-not-redirect
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$
RewriteRule .* /index.html [L,R=301]
So my amended question is
How to tell google my content is gone and redirect all requests for content (bookmarked pages for example or external links) made to my site to /index.html
Update
ErrorDocument 410 /error-docs/error410.html
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/error-docs/
RewriteCond %{REQUEST_URI} !=/index.html
RewriteCond %{REQUEST_URI} !=/
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$
RewriteRule .* - [G]
almost works
But I want to return 410 on all files in 4 subfolders and whatever is under them
I have
/index.html
/images/
/js/
/css/
/unwantedfolder/with/stuff/imagesandhtml
/anotherunwantedfolder/with/stuff/imagesandhtml
I want to give 410 for now on all request to anywhere in the unwanted folders
If I add
RewriteRule ^unwantedfolder - [G]
like this
ErrorDocument 410 /error-docs/error410.html
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/error-docs/
RewriteCond %{REQUEST_URI} !=/index.html
RewriteCond %{REQUEST_URI} !=/
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$
RewriteRule .* - [G]
RewriteRule ^unwantedfolder - [G]
nothing happens to
http://www.myserver.com/unwantedfolder/bla/images/someimage.png
It shows without any redirection, likely due to the !\.(gif|jpe?g|png|css|js)$
earlier
whereas
http://www.myserver.com/unwantedfolder/bla/somepage.html
does get a error410 page