Mobile app version of vmapp.org
Login or Join
Shelley277

: 410 response code in subdirectory I have an htaccess file in one of my subdirectories. I'm trying to throw a 410 response code for .doc and .pdf files in my uploads directory for my multisite

@Shelley277

Posted in: #Htaccess

I have an htaccess file in one of my subdirectories. I'm trying to throw a 410 response code for .doc and .pdf files in my uploads directory for my multisite installation.

So my .htaccess file is in this directory: wp-content/uploads/sites/2/2016

and looks like this:

RedirectMatch gone "/01/.pdf$"


So shouldn't this throw a 410 for the following URL:

wp-content/uploads/sites/2/2016/01/my-file.pdf


The full url is currently returning a 404.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Shelley277

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ann8826881

RedirectMatch gone "/01/.pdf$"



This would match URLs that end in /01/.pdf, so won't match the given URL that ends /01/my-file.pdf.

However, it may be preferable to use mod_rewrite in order to override the standard WordPress directives in the root of the site.

Try the following instead to send a 410 Gone for all .doc and .pdf files in the directory (.htaccess file should be the appropriate subdirectory):

RewriteEngine On
RewriteRule .(doc|pdf)$ - [G]


UPDATE: If you are still getting a 404 for these resources (which don't exist) then it's possible that you have a custom error document that overrides the HTTP status code. Try resetting this by adding the following before the above directives:

ErrorDocument 410 default

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme