LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 08:54 AM   #1
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Rep: Reputation: 103Reputation: 103
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, 04:36 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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



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 01:18 AM
Apache httpd.conf redirect https keanduong Linux - Server 9 11-03-2012 03:04 AM
apache 2.0 https to https redirect struct Linux - Software 1 04-22-2011 05:43 PM
Redirect https apache requests to folder not in apache root bax Linux - Enterprise 4 04-12-2010 01:16 PM
Apache & Squirrelmail:Redirect to https? mac_phil Linux - Software 1 05-24-2004 03:52 AM

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

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

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
Open Source Consulting | Domain Registration