RewriteEngine On RewriteCond %{HTTP_HOST} ^www\. [NC] RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Category: HTACCESS
Force HTTPS
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Change PHP version
PHP 7.4
# Use PHP 7.4 AddHandler application/x-httpd-php74 .php
PHP 8.0
# Use PHP 8.0 AddHandler application/x-httpd-php80 .php
PHP 8.3
# Use PHP 8.3 AddHandler application/x-httpd-php83 .php
Prevent direct access to a file
Method 1
<Files "example.txt"> Deny from all </Files>
Method 2
RewriteEngine On RewriteCond %{REQUEST_URI} ^/example.txt$ RewriteRule .* /error-page.html [L]
Redirect url
Method 1
Redirect 301 /oldpage.html http://example.com/newpage.html
Method 2
RewriteEngine On RewriteRule ^oldpage.html$ http://example.com/newpage.html [R=301,L]