How to disable mod_security on shared hosting via .htaccess

Question: I’m installing a new php cart and get the error :

Your webserver has the mod_security module enabled. As a result, you may see the “403 Forbidden” or “Not Acceptable” error messages after submitting forms that contain “curl”, “perl”, “set”, etc. It is recommended to disable this module or reconfigure it so that these words are not forbidden.*

How can I disable mod_security?

Answer:

To disable mod_security, add the following to a .htaccess file in the base directory for the script you are trying to install.


SecFilterEngine Off
SecFilterScanPOST Off

Hide index.html from URL in address bar

Question: I want users to my site to always go to the base URL http://site.com/ – I never want the index page to show. For example, I want http://site.com/index.html to redirect automatically to http://site.com without the index.html

Answer:

Create a .htaccess file (or add to your existing .htaccess) in the top level directory for your site and add the following line:


RewriteEngine on

RewriteRule ^index\.html$ / [R=301,L]

The line :


RewriteEngine on

may already be in your existing .htaccess. If so, do not duplicate it.

Increase php timeouts with .htaccess

If you are running mod_php you may experience problems with big uploads and imports (or other long running processes).

You can adjust php’s default timeouts using a .htaccess file.

Create a file called .htaccess and put the code:

# increase php time-out limits
php_value max_execution_time 1000
php_value max_input_time 1000

inside it. Put the .htaccess file into the top-most directory of your site. If you already have a .htaccess
file, add the code above to the end of it.

This should solve you problem in most cases.

If it does not, try to increase the times (1000). If the problem persists, open a support ticket and include the URL, click path and any needed usernames and passwords. We will duplicate the problem and attempt to adjust your php execution times to make your script work.

Note: if you are running php as a cgi, you’ll need to adjust your /etc/php.ini file. Adding directives to .htaccess files has no effect on installs using php-cgi.

Running a different php version for only part of my website

Q: I want to change my PHP version to for only part of my website. How do I do this? Hi,

A: The recommended method is to make a file called:

.htaccess

(the leading dot is required)

inside the top level directory for which you want to change the php version.

Inside the file put this:

AddHandler custom-php .php .pcgi .phtml .inc .phtml~ .php~ .inc~ .html~
Action custom-php /cgi-sys/php5.3

Replace php5.3 with which ever version you want to run
You can also add other file extensions to the list in the first line.

To run a part of your site as mod_php, add this line to a .htaccess in the directory you want to run as mod_php :


AddHandler application/x-httpd-php .php3 .phtml .php .php4 .php~ .php3~ .php4~ .phtml~ .inc .inc~