Home > Mobile >  Strange RewriteRule causes errors
Strange RewriteRule causes errors

Time:11-01

I use PrestaShop on Litespeed server, here is a part of .htaccess of admin panel:

    # Keep legacy entry points
    RewriteRule ^(ajax|ajax_products_list|ajax-tab|backup|cron_currency_rates)\.php - [P]
    RewriteRule ^(displayImage|drawer|footer\.inc|functions|get-file-admin)\.php - [P]
    RewriteRule ^(grider|header\.inc|init|login|password|pdf|searchcron)\.php - [P]

    # If the URL is a legacy on index.php?controller=..., do not rewrite (let the legacy take it)
    RewriteCond  %{QUERY_STRING} (^|&)controller=|(^|&)tab=
    RewriteRule .* - [P]

I see many logs regarding those:

2021-10-30 16:01:17.163186  WARN    [225891] [T0] [REWRITE] Detects bad proxy action without updating target URL. Ignore. while parsing: RewriteRule ^(ajax|ajax_products_list|ajax-tab|backup|cron_currency_rates)\.php - [P]
2021-10-30 16:01:17.163218  WARN    [225891] [T0] [REWRITE] Detects bad proxy action without updating target URL. Ignore. while parsing: RewriteRule ^(displayImage|drawer|footer\.inc|functions|get-file-admin)\.php - [P]
2021-10-30 16:01:17.163228  WARN    [225891] [T0] [REWRITE] Detects bad proxy action without updating target URL. Ignore. while parsing: RewriteRule ^(grider|header\.inc|init|login|password|pdf|searchcron)\.php - [P]
2021-10-30 16:01:17.163243  WARN    [225891] [T0] [REWRITE] Detects bad proxy action without updating target URL. Ignore. while parsing: RewriteRule .* - [P]
2021-10-30 16:01:17.581695  WARN    [225890] [T0] [REWRITE] Detects bad proxy action without updating target URL. Ignore. while parsing: RewriteRule .* - [P]

Can anyone describe what are those RewriteRules and why I get those errors?


Thanks!

CodePudding user response:

The use of the P flag is clearly an error in this context. I would have said it was a typo, was it not on every rule! They probably meant to use PT (passthrough), although L (last) (or END) would be preferable.

The purpose of these directives is to prevent further processing (ie. other rewrites from occurring) of these particular "legacy" URLs.

Change [P] to [L] on all 4 of these rules to resolve this.

For example:

RewriteRule ^ - [L]

(Also changing .* to ^ on the last rule, since it doesn't need to actually match everything, it just needs to be successful for everything.)

  • Related