[users@httpd] How to redirect a url to https?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ok,  I've been scratching my head for a couple days now over something
that is probably very simple, but I can't seem to get to work.  What I
want to do is redirect all requests to a particular resource like
http://www.example.com/somepath to https://example.com/somepath.  Sounds
simple enough, but I just haven't been able to make it work.  If
possible, I want to have the configuration options in an external file,
then be able to include that file in both my :80 and :443 servers.  Then
apache would just Do The Right Thing(tm) and I would be happy... :)

Here is what I have tried (note, I have to use Location, because this is
a proxied path, and not a local directory).
  
<Location /somepath/ >
   RewriteEngine        on
   RewriteBase          /somepath
   RewriteCond          %{HTTPS} !=on
   RewriteCond          %{REQUEST_URI} ^/somepath/.*
   RewriteRule          /somepath/(.*)  \
https://www.example.com/somepath/$1 [R=Permanent,L]
   ... authentication stuff ...
   require valid-user
</Location>
ProxyPass /somepath/       http://otherhost.example.com/somepath/

But for whatever reason, when i try to access /somepath/, it lets me
authenticate without ssl, and never redirects me.


I've also tried something like this:
<IfModule !mod_ssl.c>
   RewriteEngine        on
   RewriteCond          %{REQUEST_URI} ^/somepath/.*
   RewriteRule          /somepath/(.*) https://www.example.com/somepath/$1 [R=Permanent,L]
</IfModule>
<IfModule mod_ssl.c>
   <Location /somepath/ >
      ... authentication stuff ...
      require valid-user
   </Location>
   ProxyPass /somepath/       http://otherhost.example.com/somepath/
</IfModule>

But for whatever reason, the authentication and <Location> stuff is showing 
up in my :80 server as well. Does that stuff get included in both virtual
hosts if mod_ssl is loaded?

Thanks for any suggestions.

Jason Martens

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux