Htaccess

From Wiki
Revision as of 16:50, 19 June 2024 by Qljca (talk | contribs)
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>