LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-30-2016, 09:54 AM   #1
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,052

Rep: Reputation: 78
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.
 
Old 01-30-2016, 05:36 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,630

Rep: Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808
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
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] redirect https non-www Apache rahmad Linux - Server 16 10-20-2016 02:18 AM
Apache httpd.conf redirect https keanduong Linux - Server 9 11-03-2012 04:04 AM
apache 2.0 https to https redirect struct Linux - Software 1 04-22-2011 06:43 PM
Redirect https apache requests to folder not in apache root bax Linux - Enterprise 4 04-12-2010 02:16 PM
Apache & Squirrelmail:Redirect to https? mac_phil Linux - Software 1 05-24-2004 04:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration