.htaccess code
Use php 5.3
AddHandler application/x-httpd-php53s .php
You may deny access to certain files using the .htaccess code which follows. This code denies access to anything listed under “FIlesMatch”
# multiple file types<FilesMatch ".(htaccess|htpasswd|ini|phps|sh|config)$">Order Allow,DenyDeny from all</FilesMatch>
# disable directory browsing
Options All -Indexes
# enable directory browsingOptions All +IndexesYou may setup a deny list with the following code
#Deny List
order allow,deny
deny from 123.123.123.123 #specify a specific address
deny from 123.123.123.123/30 #specify a subnet range
deny from 123.123.* #specify an IP address wildcard
allow from all
You may setup an allow list with the following code
#Allow List
order allow,deny
allow from 123.123.123.123 #specify a specific address
allow from 123.123.123.123/30 #specify a subnet range
allow from 123.123.* #specify an IP address wildcard
deny from all
You may redirect from non www. over to www.yourdomain.com make sure to replace this code with the correct domain name
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$
RewriteRule ^/?$ "http\:\/\/www\.yourdomain\.com\/" [R=301,L]
Block your website to everyone except yourself: good for fixing hacked websites/ building a new site.
ErrorDocument 503 "Our website is temporarily closed for maintenance."
RewriteEngine On
# TO ALLOW YOURSELF TO VISIT THE SITE, CHANGE YOUR IP ADDRESS.
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123$
RewriteRule .* - [R=503,L]
force https traffic, good when a regular redirect/ rewrite gives a loop error
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Wildcard SSL certificate .htaccess code
RewriteEngine on
# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(subdomain.)?yourmaindomain.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change yourdomain.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(subdomain.)?yourmaindomain.com$
RewriteRule ^(/)?$ subdirectory/index.php [L]
