LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   apache redirect to https isn't working (https://www.linuxquestions.org/questions/linux-newbie-8/apache-redirect-to-https-isnt-working-4175568805/)

vincix 01-30-2016 08:54 AM

apache redirect to https isn't working
 
Hi,

I've installed owncloud on my Centos 7 VPS. It works fine and I've also enabled ssl. Of course, the problem now is that clients are not automatically redirected to https. So I tried using Redirect / https://example.com, but it doesn't work. It says, "the page isn't directing properly" on Firefox.
In Safari it asks me to accept a certificate (my self-signed certificate) and then it says "Safari can't open the page".

If I try running example.com/owncloud, it's the same thing.

Here is part of my httpd.conf:
Code:

ServerRoot "/etc/httpd"
Listen 0.0.0.0:80
Listen 0.0.0.0:443
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@example.com
ServerName example.com
 
DocumentRoot "/var/www/html"
Redirect permanent / https://example.com/
Alias /owncloud /var/www/html/owncloud

<Directory "/var/www/html/owncloud">
        Options Indexes FollowSymlinks
        AllowOverride All
        Order allow,deny
        allow from all
</Directory>

What could trigger this weird redirect?
It's worth mentioning that if I delete the Redirect directive, the server works fine.

bathory 01-30-2016 04:36 PM

Hi,

You should put the Redirect directive inside the http vhost definition or else you're going in a loop.
And you need a trailing slash at the https URL:
Code:

<VirtualHost *:80>
ServerName example.com
...
Redirect permanent / https://example.com/
</VirtualHost>

Regards


All times are GMT -5. The time now is 11:24 AM.