I
I
Ivan Ivanovich2019-04-27 18:31:09
Apache HTTP Server
Ivan Ivanovich, 2019-04-27 18:31:09

How to merge 2 teams?

Hello. Please help me combine 2 commands:

  1. To redirect from http to https
  2. To remove .html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.html [NC,L]

Is that right?
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.html [NC,L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AUser0, 2019-04-27
@IwanQ

Works correctly only if .htaccess is in the DOCUMENT_ROOT root directory.
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule "^(.*)\.html$" https://%{HTTP_HOST}$1 [R,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question