Redirect HTTP to HTTPS in .htaccess

If you want to redirect HTTP to HTTPS and want to add www with each URL, use the htaccess below:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L] 

It will first redirect HTTP to HTTPS and then it will redirect to https://www

😉

APACHE + MOD_SEC 413 or 44 ~ Request Entity Too Large ;-)

My friend ran into a problem with my CENTOS Server. The problem was related to a error in Opencart.

“Error 413 Request Entity is Too Large…”

You need to edit mod_security.conf to fix this issue

/etc/httpd/conf.d/mod_security.conf

Locate this part near the top of the configuration

# Default recommended configuration
SecRuleEngine On “You may turn this Off, until you fix thing, but put it back On
SecRequestBodyAccess On
SecRule REQUEST_HEADERS:Content-Type “text/xml” \
“id:’200000′,phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML”
SecRequestBodyLimit 531072
SecRequestBodyNoFilesLimit 531072
SecRequestBodyInMemoryLimit 531072
SecRequestBodyLimitAction Reject

Now change the value of those two configuration

SecRequestBodyLimit 2147483647   (2GB unlimited value)
SecRequestBodyNoFilesLimit 5242880  (This will fix the 413 error)
SecRequestBodyInMemoryLimit 531072
SecRequestBodyLimitAction Reject

Restart Apache

systemctl restart httpd

ENJOY!

Cheers Dejan from SERBIA! TEAMWORK!!!