.htaccess general catch all RewriteRule with preceding 410 RewriteRules

I have the following setup: We are redirecting one domain named www.redirected-website.com (wordpress) to another named www.final-website.com (also wordpress). There are specific RewriteRules which cannot be handled by general catch all rule and we need to return 410: RewriteEngine On RewriteRule ^path/link1/?$ "-" [G,NC] RewriteRule ^path2/link2/?$ "-" [G,NC] RewriteRule ^path3/link3/?$ "-" [G,NC] ...some more specific RewriteRules bellow RewriteRule ^(.*)$ https://www.final-website.com/path4/$1 [R=301,L] The problem which I am facing is that despite the fact that the general catch all rules is located at the bottom of the .htaccess file it still rewrites the 410 rules which in my understanding should stop processing the iteration of the htaccess file: https://httpd.apache.org/docs/current/rewrite/flags.html#flag_g https://httpd.apache.org/docs/current/rewrite/flags.html#flag_end I've also tested adding the END flag to the 410s but result is same ... Final RewriteRule is being applied: root@server:~# curl -I -L https://www.redirected-website.com/path/link1/ HTTP/2 301 x-frame-options: DENY location: https://www.final-website.com/path4/410.shtml Can you please help me understand that weird behavior. Thank you!

Comment (1)

Jese Leos

August 19, 2024

Verified user

@C3roe pointed me to the correct direction. I am having definition for ErrorDocument 410 which points exactly to this file 410.shtml. Adding on top of htaccess: ErrorDocument 410 " " fixed the issue.

You’ll be in good company