Rewriting URL to include https
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Rewriting URL to include https




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Rewriting URL to include https  
laredotornado@zipmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-25-07 06:39 AM

Hi,

Using Apache 2.0, how would I construct an .htaccess file that would
redirect the page visit if the URL began with "http://" to "https://".
Thus, if someone typed in

http://mydomain.com/admin/

they'd be redirected to

https://mydomain.com/admin/

?  Thanks, - Dave






[ Post a follow-up to this message ]



    Re: Rewriting URL to include https  
Rik


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-25-07 12:21 PM

On Thu, 25 Jan 2007 05:43:16 +0100, laredotornado@zipmail.com  =

<laredotornado@zipmail.com> wrote:

> Hi,
>
> Using Apache 2.0, how would I construct an .htaccess file that would
> redirect the page visit if the URL began with "http://" to "https://".=

> Thus, if someone typed in
>
> http://mydomain.com/admin/
>
> they'd be redirected to
>
> https://mydomain.com/admin/

See this url for conditional rewriting:
http://httpd.apache.org/docs/1.3/mo...tml#RewriteCond


RewriteCond ${SERVER_PROTOCOL}  !^https [NC]
RewriteRule .* https://${HTTP_HOST}${REQUEST_URI} [L,R=3D301,Q
SA]

Grtz,
-- =

Rik Wasmus
* I'm testing several new newsreaders at the moment. Please excuse  =

possible errors and weird content. *





[ Post a follow-up to this message ]



    Re: Rewriting URL to include https  
laredotornado@zipmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-26-07 12:27 AM

Hi,

I added your code to my .htaccess file ...


AuthType Basic
AuthUserFile "/home/remanr/www/www/admin/.htpasswd"
AuthName Limited!
require valid-user

RewriteEngine On
RewriteCond ${SERVER_PROTOCOL}  !^https [NC]
RewriteRule .* https://${HTTP_HOST}${REQUEST_URI} [L,R=301,QSA
]


but when I uploaded it, I got a page not found error when I entered the
URL.  I was actually redirected to Google with a
"${http_host}${request_uri}" in the search string.  Any ideas? -


On Jan 25, 5:00 am, Rik <luiheidsgoe...@hotmail.com> wrote:
> On Thu, 25 Jan 2007 05:43:16 +0100, laredotorn...@zipmail.com
>
> <laredotorn...@zipmail.com> wrote: 
> 
> 
> 
> 
>
> RewriteCond ${SERVER_PROTOCOL}  !^https [NC]
> RewriteRule .* https://${HTTP_HOST}${REQUEST_URI} [L,R=301,Q
SA]
>
> Grtz,
> --
> Rik Wasmus
> * I'm testing several new newsreaders at the moment. Please excuse
> possible errors and weird content. *






[ Post a follow-up to this message ]



    Re: Rewriting URL to include https  
Rik


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-26-07 12:27 AM

On Thu, 25 Jan 2007 20:52:37 +0100, laredotornado@zipmail.com  =

<laredotornado@zipmail.com> wrote:

> Hi,
>
> I added your code to my .htaccess file ...
>
>
> AuthType Basic
> AuthUserFile "/home/remanr/www/www/admin/.htpasswd"
> AuthName Limited!
> require valid-user
>
> RewriteEngine On
> RewriteCond ${SERVER_PROTOCOL}  !^https [NC]
> RewriteRule .* https://${HTTP_HOST}${REQUEST_URI} [L,R=3D301
,QSA]
>
>
> but when I uploaded it, I got a page not found error when I entered th=
e
> URL.  I was actually redirected to Google with a
> "${http_host}${request_uri}" in the search string.  Any ideas? -

Je m'excuse, was heavy into php at that moment, The $ should be %:

RewriteCond %{SERVER_PROTOCOL}  !^https [NC]
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=3D301,Q
SA]
-- =

Rik Wasmus
* I'm testing several new newsreaders at the moment. Please excuse  =

possible errors and weird content. *





[ Post a follow-up to this message ]



    Re: Rewriting URL to include https  
laredotornado@zipmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-27-07 12:27 AM

Thanks for the reply.  Unfortunately, I still get the error (on PC
Firefox)

The page isn't redirecting properly

when I type in "mydomain.com/admin" after uploading the new .htaccess
file


AuthType Basic
AuthUserFile "/home/remanr/www/www/admin/.htpasswd"
AuthName Limited!
require valid-user

RewriteEngine On
RewriteCond %{SERVER_PROTOCOL}  !^https [NC]
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,QSA
]


- Dave


On Jan 25, 1:57 pm, Rik <luiheidsgoe...@hotmail.com> wrote:
> On Thu, 25 Jan 2007 20:52:37 +0100, laredotorn...@zipmail.com
>
>
>
> <laredotorn...@zipmail.com> wrote: 
> 
> 
> 
> 
>
> RewriteCond %{SERVER_PROTOCOL}  !^https [NC]
> RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,Q
SA]
> --
> Rik Wasmus
> * I'm testing several new newsreaders at the moment. Please excuse
> possible errors and weird content. *






[ Post a follow-up to this message ]



    Re: Rewriting URL to include https  
Rik


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-27-07 12:27 AM

laredotornado@zipmail.com <laredotornado@zipmail.com> wrote:

Please do not toppost.
 
=
[vbcol=seagreen] 
[vbcol=seagreen] 
>
> The page isn't redirecting properly
>
> when I type in "mydomain.com/admin" after uploading the new .htaccess
> file

Yes, when you type in that, then what happens??? Hwt is the error you ge=
t?

Maybe you should enable a RewriteLog so we can follow it.
[vbcol=seagreen]
> AuthType Basic
> AuthUserFile "/home/remanr/www/www/admin/.htpasswd"
> AuthName Limited!
> require valid-user
>
> RewriteEngine On
> RewriteCond %{SERVER_PROTOCOL}  !^https [NC]
> RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=3D301,QSA][/v
bcol]

Works OK here, alternatively try:

RewriteCond %{HTTPS}  !^on [NC]
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=3D301,Q
SA]
-- =

Rik Wasmus





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 02:28 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register