Htaccess: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 75: | Line 75: | ||
deny from all | deny from all | ||
allow from x.x.x.x | allow from x.x.x.x | ||
</pre> | |||
==PHP Code in HTML== | |||
For Cloudlinux | |||
<pre> | |||
AddHandler application/x-httpd-lsphp .htm .html .shtml | |||
AddHandler application/x-httpd-lsphp .php .htm .html | |||
</pre> | |||
For Easy Apache: | |||
<pre> | |||
AddHandler application/x-httpd-ea-php72 .htm .html .php | |||
</pre> | </pre> | ||
Revision as of 09:04, 20 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>
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