V
V
VladimirDronik2018-07-19 08:55:32
htaccess
VladimirDronik, 2018-07-19 08:55:32

How to setup htaccess for www and http?

Tell me how to configure htaccess to redirect from www to https and from http to https?
I do it like this.
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]
#RewriteCond %{HTTP_HOST} ^www.v-son \.ru$ [NC]
#RewriteRule ^(.*)$ v-son.ru/$1 [R=301,L]
#RewriteCond %{SERVER_PORT} ^80$ [OR]
#RewriteCond %{HTTP} =on
# RewriteRule ^(.*)$ https://v-son.ru/$1 [R=301,L]
Link v-son.ru/postelnoe-belyo/all leads to https://v-son.ru/index .php, but should onhttps://v-son.ru/postelnoe-belyo/all
_ parameters after the site name are not accepted.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene M., 2018-07-19
@VladimirDronik

I have it done like this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www(.*)$ [NC]
RewriteRule ^(.*)$ https://domain.ru%{REQUEST_URI} [R=301,L]
RewriteCond %{SERVER_PORT} !^443 $
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php [L]

Everything is working.

A
Arman, 2018-07-19
@Arik

htaccess from H5BP may seem very large, but if you look, there is a lot of useful stuff

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question