Htaccess: Difference between revisions
Jump to navigation
Jump to search
(Created page with "==Redirect IP to domain==") |
No edit summary |
||
| Line 1: | Line 1: | ||
==Redirect IP to domain== | ==Redirect IP to domain== | ||
<pre> | |||
Options +FollowSymLinks | |||
RewriteEngine on | |||
RewriteCond %{HTTP_HOST} ^555\.555\.555\.555 | |||
RewriteRule (.*) http://www.example.com/$1 [R=301,L] | |||
</pre> | |||
==Force SSL== | |||
<pre> | |||
RewriteCond %{SERVER_PORT} ^80$ | |||
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] | |||
</pre> | |||
==Redirect Main domain to a sub folder== | |||
<pre> | |||
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] | |||
</pre> | |||
==Redirect Every Request to index page== | |||
<pre> | |||
# 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> | |||
</pre> | |||
==Redirect Single Page to HTTPS== | |||
<pre> | |||
RewriteCond %{HTTPS} off | |||
RewriteCond %{REQUEST_URI} ^/marine-australia/login/ | |||
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] | |||
</pre> | |||
==Redirect Query string to homepage== | |||
<pre> | |||
RewriteCond %{QUERY_STRING} [0-9a-zA-Z_-]+$ | |||
RewriteRule ^(.*)$ https://www.example.com/? [R=301,L] | |||
</pre> | |||
==Redirect all pages to single URL== | |||
<pre> | |||
<IfModule mod_rewrite.c> | |||
RewriteEngine on | |||
RewriteRule ^(.*)$ http://johnmeier.com/ [R=301,L] | |||
</IfModule> | |||
</pre> | |||
==Disable POST Requests== | |||
<pre> | |||
<Limit POST> | |||
order deny,allow | |||
deny from all | |||
allow from 127.0.0.1 | |||
</Limit> | |||
</pre> | |||
Revision as of 16:50, 19 June 2024
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>