Last active
August 31, 2022 00:34
-
-
Save w-jerome/085f41be5e956f874a36697015352733 to your computer and use it in GitHub Desktop.
HTACCESS - Tips
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Doc: https://www.askapache.com/htaccess/ssl-example-usage-in-htaccess/#rewrite-http-to-https-no-mod_ssl | |
| RewriteEngine on | |
| # REMOVE TRAILING SLASH | |
| RewriteCond %{REQUEST_FILENAME} !-d | |
| RewriteRule ^([a-z]+)/(.*)/$ /$1/$2 [L,R=301] | |
| # END REMOVE TRAILING SLASH | |
| # https and www for OVH | |
| RewriteCond %{ENV:environment} production | |
| RewriteCond %{HTTPS} off | |
| RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
| RewriteCond %{ENV:environment} production | |
| RewriteCond %{HTTP_HOST} !^www\. [NC] | |
| RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
| # Redirection domaine with www | |
| RewriteCond %{HTTP_HOST} ^site\.fr | |
| RewriteRule (.*) http://www.site.fr/$1 [R=301,L] | |
| # Redirection du domaine avec www | |
| RewriteCond %{HTTP_HOST} !^www\.site\.com$ [NC] | |
| RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1 | |
| RewriteCond %{REMOTE_ADDR} !^::1 | |
| RewriteRule ^(.*)$ https://www.site.com/$1 [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment