A very strange situation appeared.

Here's my .htaccess:

RewriteEngine On
RewriteRule (.*)\.ready / [R=410,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

The line RewriteRule (.*)\.ready / [R=410,L] is not executed until I:

  • change 410 to 301 ?? (then it is working, how can this happen ?)
  • remove the BEGIN WP / END WP block, if so, line is executed properly

An example URL that need a 410 code : https://todaycycling.com/actualites-cyclisme/5t0e232502yg9t9/0002ap3_0198jqi/3613qh5786/.ready

  • You may try to add this one after the WP RewriteCond : RewriteCond %{Request_URI} !^.*.ready
    – Elex
    Commented Dec 15, 2017 at 8:10
  • Nope, it does not work :/
    – Alexsoyes
    Commented Dec 15, 2017 at 8:31
  • 1
    Sounds strange. Is there anything else in your .htaccess? You shouldn't have to remove the WordPress block, since the rules are looked at in order of appearance. Also, R=410 implies the L, but for clarity, I'd simply use G.
    – janh
    Commented Dec 15, 2017 at 8:55
  • Yes, only that. What is disturbing me is that if I replace 410 -> 301, it does work !
    – Alexsoyes
    Commented Dec 15, 2017 at 9:06

1 Answer 1


Try resetting the default error document at the start of your .htaccess file:

ErrorDocument 410 default

If you have a custom 410 error document defined elsewhere in your server config then this could end up being routed by WordPress. (I've encountered some shared hosts that (for some reason) define a custom "default" ErrorDocument in the server config. If this error document does not exist then it will end up being rewritten to index.php and processed by WordPress.)

Incidentally, when you use a status code other than 3xx in the RewriteRule then you should simply use a hyphen (-) in the RewriteRule substitution. (It's ignored anyway.) And as @janh mentioned in comments, "R=410 implies the L, but for clarity, I'd simply use G". So, this is better written as:

RewriteRule \.ready - [G]

To match ".ready" anywhere in the URL-path. The (.*) prefix is superfluous, and unnecessarily capturing the pattern is wasteful. If this should only occur at the end of the URL-path, include an end-of-string anchor ($). eg. \.ready$

  • 1
    You are so right ! ErrorDocument 410 default did the trick, thank you very much ! And thank you also for the regex explanation, I am a regex newbie :)
    – Alexsoyes
    Commented Dec 17, 2017 at 8:35

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.