Ad

Apache L And END Flag Are Ignored Depending Of The Environement

- 1 answer

i'm running a Wordpress on a cpanel and i'd like to user this htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(\/|)\d{4,7} - [L,NC,G]
    RewriteRule ^(\/|)\d{4,7} - [END,NC,G]

    
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
    RewriteRule ^.*$ https://www.%1%{REQUEST_URI} [L,NE,R=301,QSD]
</IfModule>

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

If i use this htaccess on a cpanel environment, when i access to a url like : https://www.example.com/12345 i got a 404 instead of a 410

If a i run it on a clean environment using a linux turnkey : it's working properly i got a 410 It seems on a cpanel environment the [L] or [END] flag are ignored

Ad

Answer

Try resetting the 410 error document to default:

ErrorDocument 410 default

I don't think the problem is related to cPanel as such, but it's possible that the 410 is being converted to a 404 by a server-defined ErrorDocument, which is not uncommon on shared server environments.

RewriteRule ^(\/|)\d{4,7} - [L,NC,G]
RewriteRule ^(\/|)\d{4,7} - [END,NC,G]

But having both these directives doesn't make sense. The second directive is never processed.

Strictly speaking, the G flag impliesL anyway. So, the L flag is superfluous. (As is the NC flag.)

But using L or END in this context makes no difference.

Ad
source: stackoverflow.com
Ad