Skip to content

Apply .htaccess rule for controller and cron

I have some long-running scripts that should bypass the “Connection Timeout” set up in LiteSpeed.

I want to do it in the .htaccess file and it works if I apply this rule (*RewriteRule . – [E=noabort:1, E=noconntimeout:1]**), but I would like to apply it only for some controllers and cronjobs. Controllers are usually executed from the browser, but cronjobs are executed when they are scheduled or by executing one CLI command (php bin/magento vendor:updateproducts:run).

Considering I have the following two files and their following paths, one controller and one cron, how should the RewriteCond look like so that the RewriteRule will be applied only for these two files?

Controller Path: /home/staging/public_html/app/code/Vendor/Products/Controller/Index/Save.php

Cron Path: /home/staging/public_html/app/code/Vendor/Products/Cron/Update.php

Thank you!