0

I've deleted several pages and tags from my site, and bases on my SEO recommendations I've redirected them to 410.

I've done that in my .htaccess file this way:

RewriteRule ^tag/lorem/?$ - [G]
RewriteRule ^tag/ipsum/?$ - [G]
RewriteRule ^tag/dolor/?$ - [G]
RewriteRule ^tag/amet/?$ - [G]

At the end of the .htaccess I've defined the ErrorDocument 410 and I want it to go to a page I've created on Wordpress

ErrorDocument 410 http://myhost.localhost/error-410/

The thing is it sends me to that page, but it gives me a 302 instead a 410 on the headers

Request URL: http://myhost.localhost/tag/routers/
Request Method: GET
Status Code: 302 Found
Remote Address: [::1]:80
Referrer Policy: no-referrer-when-downgrade

What am I doing wrong?

Thanks in advance

4
  • You can't do this in Apache/.htaccess when using WordPress unfortunately. When you specify an absolute URL as the ErrorDocument it will indeed trigger a 302 redirect, however, if you use a root-relative URL-path (as you would normally/should do) then it won't work with WordPress since WP looks at the REQUEST_URI variable in order to route the URL. You need to do this entirely inside WordPress. Perhaps include code in your 404.php file to check for these URLs and override the response?
    – MrWhite
    Commented Oct 1, 2020 at 10:12
  • What you mean inside wordpress @MrWhite ? Commented Oct 1, 2020 at 10:36
  • As in the PHP code that drives the WordPress CMS. Aside: If you wanted to serve a non-WordPress 410 error document then you could do this using ErrorDocument in .htaccess.
    – MrWhite
    Commented Oct 1, 2020 at 10:43
  • What I don't understand is how can I manage this inside WP. Commented Oct 1, 2020 at 12:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.