1

I want to add 'rewrite condition' in .htcaccess but unfortunately I don't have access of that. Can I write conditions in functions.php ? If yes, how to achieve that ? I want to add these lines:

RewriteCond %{QUERY_STRING} ^.{1000,}$
RewriteRule ^wp-admin/load-scripts\.php$ - [F]
8
  • Aside: The directives as posted don't quite make sense. The solitary f at the end should be [F]. Is the RewriteRule pattern intentionally uppercase?
    – MrWhite
    Sep 22, 2021 at 9:40
  • ref- hackerone.com/reports/925425
    – Ricky
    Sep 22, 2021 at 9:44
  • Ok, but that rule is certainly wrong. It should read RewriteRule ^wp-admin/load-scripts\.php$ - [NC,F]. The rule as written (all uppercase and no NC flag) would fail to match the request it is trying to block. The NC flag would be required if you are running this on a Windows platform. And the lone f at the end would trigger an immediate 500 Internal Server Error (since it's entirely invalid syntax).
    – MrWhite
    Sep 22, 2021 at 12:09
  • ok, thanks!! do u know how to achieve that via functions or any php code? I have edited my code
    – Ricky
    Sep 22, 2021 at 12:57
  • 1
    I'm not sure sorry. Whatever code you add, it needs to still edit the .htaccess file. If you don't have permission to edit .htaccess (or there is no .htaccess) file then this isn't going to be possible. (Has this vulnerability not already been "fixed" in load-scripts.php?)
    – MrWhite
    Sep 22, 2021 at 13:36

1 Answer 1

1

use this https://wordpress.org/plugins/wp-htaccess-editor/, if you are not willing to use any plugin, understand the code and implement in functions.php or your own custom plugin. cheers.

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.