Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I would like to 410 an entire directory - I deleted my blog

I had a folder called blog on my site. I deleted it all permanently. I would like to 410 it. How do i 410 an entire folder?

e.g. my site looked like this

example.com/blog/mycoolpost1/
example.com/blog/mycoolpost2/
example.com/blog/mycoolpost3/
example.com/blog/mycoolpost4/

now posts 1,2,3,4, are dead.

so how do i specify that everything after blog, is permanently deleted. (as well as the folder 'blog' itself)

I need a htaccess line something like this...?

redirect 410 /blog/?(.*)

like image 571
Bobby Smith Avatar asked Dec 18 '11 01:12

Bobby Smith


3 Answers

The Redirect directive is the proper way to do this. You should put the following in your virtual host configuration:

Redirect 410 /blog

If you don't have access to the virtual host configuration, you can put it in the .htaccess file in your document root, or I believe you can put the following in the .htaccess file in the blog subdirectory:

Redirect 410 /

(I might be off about that, I'm not sure how exactly Redirect interacts with path resolution in .htaccess files)

like image 69
David Z Avatar answered Oct 26 '22 06:10

David Z


I don't think Redirect is the right tool for this, as it only matches the path specified. Just use:

RewriteEngine On
RewriteBase /
RewriteRule ^blog/ - [G]
like image 35
Gerben Avatar answered Oct 26 '22 05:10

Gerben


The following .htaccess would be useful when, for example, you move from a hosting to another and you reorder or delete parts of your web.

As Apache allows human syntax codes I have used permanent instead of 301 code, and gone instead of 410. You can check http protocol codes here Status Code Definitions

I placed the file on my root mynewblogaddress.com folder:

.htaccess

Redirect permanent /wordpress http://www.mynewblogaddress.com/blog/
Redirect gone /gallery2   
Redirect permanent /directory2 http://directory2.mynewblogaddress.com
like image 28
kikeenrique Avatar answered Oct 26 '22 04:10

kikeenrique