Search code examples
apache.htaccessmod-rewrite

Disable redirect on htaccess for specific url


I have htaccess as with some redirections, I want to avoid/disable/not to redirect specific URLs used in hooks to send data by POST , these URL are :

https://www.example.com/index.php?route=zoho/product/autoAdd
https://www.example.com/index.php?route=zoho/product/autoUpdate
https://www.example.com/index.php?route=zoho/product/autoDelete


htaccess do the following :
1- redirect http to https
2- redirect non www to www
3- delete index.php?route from url



the htaccess:

<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
 Order deny,allow
 Deny from all
</FilesMatch>

RewriteEngine On
RewriteBase //
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteCond %{REQUEST_URI} !^index.php?route=zoho/product.*$
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{THE_REQUEST} \ /+index\.php\?_route_=([^\ &]+)
RewriteRule ^ /%1? [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]


<IfModule mime_module>
  AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^/?$ "https\:\/\/www\.example\.com\/" [R=301,L]


<IfModule php7_module>
   php_value default_charset "UTF-8;"
   php_value memory_limit 2048M
   php_value max_execution_time 64000
   php_value upload_max_filesize 999M
   php_value mysql.connect_timeout 20
   php_flag session.auto_start Off
   php_flag session.use_only_cookies On
   php_flag session.use_cookies On
   php_flag session.use_trans_sid Off
   php_value session.cookie_httponly "On;"
   php_value session.gc_maxlifetime 3600
   php_flag display_errors Off
   php_value max_input_time 6000
   php_value max_input_vars 6000
   php_value post_max_size 4096M
   php_value session.save_path "/var/cpanel/php/sessions/ea-php72"
   php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
   php_value default_charset "UTF-8;"
   php_value memory_limit 2048M
   php_value max_execution_time 64000
   php_value upload_max_filesize 999M
   php_value mysql.connect_timeout 20
   php_flag session.auto_start Off
   php_flag session.use_only_cookies On
   php_flag session.use_cookies On
   php_flag session.use_trans_sid Off
   php_value session.cookie_httponly "On;"
   php_value session.gc_maxlifetime 3600
   php_flag display_errors Off
   php_value max_input_time 6000
   php_value max_input_vars 6000
   php_value post_max_size 4096M
   php_value session.save_path "/var/cpanel/php/sessions/ea-php72"
   php_flag zlib.output_compression Off
</IfModule>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]

Solution

  • Insert this rule just below RewriteEngine On to ignore all rules for POST requests:

    RewriteEngine On
    
    RewriteCond %{REQUEST_METHOD} POST
    RewriteRule ^ - [L]
    
    # remaining rules go below this line