Htaccess
Jump to navigation
Jump to search
Redirect IP to domain
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^555\.555\.555\.555
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Force SSL
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
Redirect Main domain to a sub folder
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?naturaltilecompany.co.uk$
RewriteCond %{REQUEST_URI} !^/shop/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /shop/$1
RewriteCond %{HTTP_HOST} ^(www.)?naturaltilecompany.co.uk$
RewriteRule ^(/)?$ shop/index.php [L]
Redirect Every Request to index page
# BEGIN Rule
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Redirect Single Page to HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/marine-australia/login/
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
Redirect Query string to homepage
RewriteCond %{QUERY_STRING} [0-9a-zA-Z_-]+$
RewriteRule ^(.*)$ https://www.example.com/? [R=301,L]
Redirect all pages to single URL
<IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^(.*)$ http://johnmeier.com/ [R=301,L] </IfModule>
Disable POST Requests
<Limit POST> order deny,allow deny from all allow from 127.0.0.1 </Limit>
Deny From Single IP
order deny,allow deny from all allow from x.x.x.x
PHP Code in HTML
For Cloudlinux
AddHandler application/x-httpd-lsphp .htm .html .shtml AddHandler application/x-httpd-lsphp .php .htm .html
For Easy Apache:
AddHandler application/x-httpd-ea-php72 .htm .html .php
Block Bad Bots
SetEnvIfNoCase User-Agent "^Yandex" search_bot SetEnvIfNoCase User-Agent "^Yahoo" search_bot SetEnvIfNoCase User-Agent "^igdeSpyder" search_bot SetEnvIfNoCase User-Agent "^Robot" search_bot SetEnvIfNoCase User-Agent "^Googlebot" search_bot SetEnvIfNoCase User-Agent "^msnbot" search_bot SetEnvIfNoCase User-Agent "^Aport" search_bot SetEnvIfNoCase User-Agent "^Mail" search_bot SetEnvIfNoCase User-Agent "^bot" search_bot SetEnvIfNoCase User-Agent "^spider" search_bot SetEnvIfNoCase User-Agent "^php" search_bot SetEnvIfNoCase User-Agent "^Parser" search_bot <Limit GET POST HEAD> Order Allow,Deny Allow from all Deny from env=search_bot </Limit>