: 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
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.
More posts by @Shelley277
1 Comments
Sorted by latest first Latest Oldest Best
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
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.