M
M
marrs2019-05-14 00:44:43
htaccess
marrs, 2019-05-14 00:44:43

How to create an https redirect rule for htaccess?

There is a React web application on the subdomain foo.site.ru
It is necessary that when accessing it via http, there should be a redirect to https
This redirect must be combined with the existing code (it directs all requests like foo.site.ru/page to index.html)

RewriteBase /
RewriteRule ^index\.html$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2019-05-14
@marrs

RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question