Archive for the ‘htaccess’ category

PHP – Turn safe_mode off with .htaccess or php.ini

November 29th, 2010

Sometimes you need to turn off safe mode on PHP for a page to load properly. There are several options to allow this and they are to

Turn off safe mode for a domain with the .htaccess file:

Put this line inside .htaccess file to turn it off:
php_value safe_mode off

if the above does not work try: 

php_flag safe_mode off

also try substituting the "off" word with: 0

Eg: php_value safe_mode 1

The other option is to create/modify a php.ini file in the cgi-bin folder and have the line

safe_mode = off

Or if you wish to turn off safe mode for the entire server

modify the /etc/php.ini and set safe_mode = On to safe_mode = off.
if you found this helpful feel free to donate to:
ZEC: t1NQp1UuqQbmnXzazbLTSreS2AbaZpRBuTM
LTC: LZyNF1qkBUA7XFz83m5xwzGgmmj1owQn9d
BTC: 1PY95KFPTEJTR7f2NnSgaB6xB9pwDJkcJz

.htaccess – redirect from http to https, port 80 to port 443

August 11th, 2010

The following .htaccess rules will autoforward an individual from a port 80 (also the regular http) to 443 (also known as https://)

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Please, note that the .htaccess should be located in the web site main folder.

In case you wish to force HTTPS for a particular folder you can use:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} somefolder
RewriteRule ^(.*)$ https://www.domain.com/somefolder/$1 [R,L]

The .htaccess file should be placed in the folder where you need to force HTTPS.

if you found this helpful feel free to donate to:
ZEC: t1NQp1UuqQbmnXzazbLTSreS2AbaZpRBuTM
LTC: LZyNF1qkBUA7XFz83m5xwzGgmmj1owQn9d
BTC: 1PY95KFPTEJTR7f2NnSgaB6xB9pwDJkcJz

.htaccess – redirect from http to https

February 23rd, 2010

The simplest code i have found so far to redirect from http to https is:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Just place this in your .htaccess file and it should work.  The same principal can be used to redirect users from https to http with

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

Finally to redirect a user from 1 port (any port) to another you could use:

RewriteEngine On
RewriteCond %{SERVER_PORT} 443
RewriteRule (.*) http://www.example.com:newport/ [R]

This will redirect from 443 to “newport”.

if you found this helpful feel free to donate to:
ZEC: t1NQp1UuqQbmnXzazbLTSreS2AbaZpRBuTM
LTC: LZyNF1qkBUA7XFz83m5xwzGgmmj1owQn9d
BTC: 1PY95KFPTEJTR7f2NnSgaB6xB9pwDJkcJz