Skip to content

How to redirect all HTTP requests to HTTPS? #272

Discussion options

You must be logged in to vote

Hi, try the following .htaccess configuration:

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

DirectoryIndex index.html yellow.php
RewriteRule ^(cache|content|system)/ error [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ yellow.php [L]
</IfModule>

As an alternative, I would recommend to redirect in your virtual hosts configuration:

<VirtualHost *:80>
        ServerName example.se
        Redirect 301 / https://example.se/
</VirtualHost>

Both alternatives work on my Apache 2.4 server. Hope this helps.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by annaesvensson
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #272 on December 27, 2020 00:33.