I've been having this problem with htaccess... I didn't learn it from scratch so I'm always fooling around a bit.. Although I would like to learn it properly as well, if anyone knows a good place, let me know as well..
So but my thing is.. Is that I want to have all non HTTPS requests redirected to the https version and that if a page shouldn't be working because of a trailing slash missing it would add it.
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://webshirts.eu/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.(php|html?|jpg|gif|css|js|svg|png|pdf)$
RewriteRule ^(.*)([^/])$ https://webshirts.eu/$1$2/ [R=301,L]
Right below there's a link to a sub folder on which it fails, this site domain is purely for testing and doesn't have a certificate. The real one does though.
https://webshirts.eu/test/
So the thing is that this doesn't work.. and I can't exactly find out why.. It worked without the top part of https !on, like perfectly, only I need to redirect the request url '/' to https.. The rest of the site always includes links to https.. So after that its gone to https, it's never going out of it.
Any help would be appreciated :) Thanks! Cheers!
Nikolai
Use this sample code to try if it works
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.