Answer the question
In order to leave comments, you need to log in
htaccess rules with protocol preservation?
Good afternoon.
I use universal htaccess for all sites.
It does not use the site name.
There is a transition to https
Removing www (well, or adding - but that's not the point)
Removing the slash at the end.
And if you comment out the lines about https, then everything works for http . I
found an error in it today.
Redirecting to without a backslash from https redirects to http - resulting in a partially insecure download.
It is necessary to add the preservation of REQUEST_SCHEME to the condition - by analogy with the transition to without www.
As I understand the line
RewriteRule ^(.*)/$ $1 [L,R=301]
should look something like this
RewriteRule ^%{REQUEST_SCHEME }(.*)/$ $1 [L,R=301]
But something didn't work out.
Help who than can.
Allow from All
AddDefaultCharset utf-8
DirectoryIndex index.php
Options -Indexes -MultiViews
RewriteEngine On
RewriteBase /
# https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# no index.php
RewriteRule ^index.php$ / [L,R=301]
RewriteRule ^index.php/$ / [L,R=301]
# no www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*) %{REQUEST_SCHEME}://%1/$1 [L,R=301]
#no end slash
RewriteCond %{REQUEST_URI} ^(.*)/$ [NC]
RewriteCond %{REQUEST_URI} !(admin.*)$
RewriteRule ^(.*)/$ $1 [L,R=301]
#fixme Работает неверно HTTPS://example.ru/captcha/ -> HTTP://example.ru/captcha - нужно вставить сохранение протокола
# framework
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
Answer the question
In order to leave comments, you need to log in
I described everything here and the slash and the drying of the protocol.
https://klondike-studio.ru/standards/standartnyy-h...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question