PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, February 17, 2022

[FIXED] Apache L and END flag are ignored depending of the environement

 February 17, 2022     apache, cpanel, mod-rewrite, wordpress     No comments   

Issue

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


Solution

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 implies L anyway. So, the L flag is superfluous. (As is the NC flag.)

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



Answered By - MrWhite
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing