LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-14-2005, 04:38 AM   #1
realos
Member
 
Registered: Jul 2002
Location: Germany
Distribution: Redhat 7.3, Debian 3.1, Knoppix 3.1, Ubuntu 6.10
Posts: 113

Rep: Reputation: 15
http-->https not working


I like all http connections to be redirected to https. Following code is in the <virtualhost *> section. Another <virtualhost *:443> is also available but ofcourse without the rewrite code. Normal https connections are working fine.

Any idea what could be the reason why it is not working?

Code:
<Directory />
        LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
        RewriteCond %{SERVER_PORT} !^443$
        RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
        Options FollowSymLinks
        AllowOverride None
        Order Allow,Deny
        Allow from All
</Directory>
 
Old 10-14-2005, 08:31 AM   #2
aznluvsmc
Member
 
Registered: Aug 2004
Location: Newmarket, Ontario
Distribution: OpenSuse 10.2
Posts: 184

Rep: Reputation: 30
The <Directory /> does not mean the web server's document root directory. It refers to the OS' root directory. You need to a rewrite rule in the directory directive that your DocumentRoot directive specifies. I'm pretty sure what you're trying to do won't work since you cannot (should not be able to) request the OS' root directory through a browser.
 
Old 10-14-2005, 08:39 AM   #3
aznluvsmc
Member
 
Registered: Aug 2004
Location: Newmarket, Ontario
Distribution: OpenSuse 10.2
Posts: 184

Rep: Reputation: 30
This is the solution from my Apache Cookbook to redirect everything to SSL. I assume in the main server portion (doesn't really say) have the following directives.

RewriteCond "%{SERVER_PORT}" "^80$"
RewriteRules "^(.*)$" "https://%{SERVER_NAME}$1" [R,L]

Or just in the main server section you can also use the directive
Redirect / https://name_of_server
to accomplish the same thing as the above.
 
Old 07-03-2006, 07:15 AM   #4
rino.caldelli
Member
 
Registered: Apr 2005
Location: perugia
Distribution: ubuntu
Posts: 181

Rep: Reputation: 31
Quote:
Originally Posted by aznluvsmc
This is the solution from my Apache Cookbook to redirect everything to SSL. I assume in the main server portion (doesn't really say) have the following directives.

RewriteCond "%{SERVER_PORT}" "^80$"
RewriteRules "^(.*)$" "https://%{SERVER_NAME}$1" [R,L]

Or just in the main server section you can also use the directive
Redirect / https://name_of_server
to accomplish the same thing as the above.
Code:
<Directory /var/www/>
RewriteEngine On
RewriteCond "%{SERVER_PORT}" "^80$"
RewriteRules "^(.*)$" "https://%{SERVER_NAME}$1" [R,L]
</Directory>
Code:
/etc/apache-ssl# apache-ssl start
Syntax error on line 1239 of /etc/apache-ssl/httpd.conf:
Invalid command 'RewriteRules', perhaps mis-spelled or defined by a module not included in the server configuration
there's a problem with the above...
 
  


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
HTTP not working, HTTPS and FTP ok smith_martin Linux - Software 6 04-29-2005 06:15 AM
http and https wennie Linux - Software 1 04-01-2005 11:47 AM
Got http, now I need to run https lothario Linux - Software 2 01-08-2005 02:30 PM
HTTP to HTTPS shegde Linux - Software 8 01-31-2003 04:29 AM
https or http? antken Programming 3 10-30-2002 05:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:50 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