RewriteRule from http to https | https://{server_name}

Hey,
I am a total noob in server administration. But I successfully have https via letsencrypt now. The website https://martha-studie.de works. But the rewirterule does not. Any help would be appreciated.

Thanks in advance

My domain is: https://martha-studie.de

I tryed in the browser: martha-studie.de

It produced this output: https://{server_name}

My web server is: Apache/2.4.25 (Debian)

The operating system my web server runs on is: Debian 9

I can login to a root shell on my machine (yes or no, or I don’t know): yes

I’m using a control panel to manage my site: yes

Please show the current vhost :80 config file - or wherever you are doing the redirection.
Or is there a redirect http to https in the control panel?

Here it is

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    
    <Directory /var/www/html/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

RewriteEngine on
RewriteCond %{SERVER_NAME} =martha-studie.de
RewriteRule ^ https://{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

something is missing…
servername …
serveralias …

There is a typo here: there should be a % before {SERVER_NAME}. So it should be:

RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
2 Likes

Ah I see. I added it but it still doesn’t seem to work when I type in martha-studie.de in the browser.

It works for me :slight_smile: Maybe your browser cached the old (wrong) redirect? Try clearing your browser’s cache.

HA omg. Its the never ending story: cache. Yes thank you it works now =)

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.