PHWinfo banniere

ACCUEIL ANNUAIRE ARTICLES COMPARATIF HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Go Back   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > alt.apache.configuration > Rewriting URL to include https
Register FAQ Members List Search Today's Posts Mark Forums Read
alt.apache.configuration Apache web server configuration issues.

Rewriting URL to include https

Reply
 
Thread Tools
Old 01/25/07, 05:43   #1
laredotornado@zipmail.com
Aucun Avatar
 
Posts: n/a
Hébergeur:
Default Rewriting URL to include https

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

  Reply With Quote
Old 01/25/07, 12:00   #2
Rik
Aucun Avatar
 
Posts: n/a
Hébergeur:
Default Re: Rewriting URL to include https

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/mod...ml#RewriteCond


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

Grtz,
--
Rik Wasmus
* I'm testing several new newsreaders at the moment. Please excuse
possible errors and weird content. *
  Reply With Quote
Old 01/25/07, 20:52   #3
laredotornado@zipmail.com
Aucun Avatar
 
Posts: n/a
Hébergeur:
Default Re: Rewriting URL to include https

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:
> > 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/mod...ml#RewriteCond

>
> RewriteCond ${SERVER_PROTOCOL} !^https [NC]
> RewriteRule .* https://${HTTP_HOST}${REQUEST_URI} [L,R=301,QSA]
>
> Grtz,
> --
> Rik Wasmus
> * I'm testing several new newsreaders at the moment. Please excuse
> possible errors and weird content. *


  Reply With Quote
Old 01/25/07, 20:57   #4
Rik
Aucun Avatar
 
Posts: n/a
Hébergeur:
Default Re: Rewriting URL to include https

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=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? -


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=301,QSA]
--
Rik Wasmus
* I'm testing several new newsreaders at the moment. Please excuse
possible errors and weird content. *
  Reply With Quote
Old 01/26/07, 21:19   #5
laredotornado@zipmail.com
Aucun Avatar
 
Posts: n/a
Hébergeur:
Default Re: Rewriting URL to include https

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:
> > 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? -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=301,QSA]
> --
> Rik Wasmus
> * I'm testing several new newsreaders at the moment. Please excuse
> possible errors and weird content. *


  Reply With Quote
Old 01/26/07, 21:30   #6
Rik
Aucun Avatar
 
Posts: n/a
Hébergeur:
Default Re: Rewriting URL to include https

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

Please do not toppost.

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

>>
>> > 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?


>> 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=301,QSA]

>
> 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 get?

Maybe you should enable a RewriteLog so we can follow it.

> 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]


Works OK here, alternatively try:

RewriteCond %{HTTPS} !^on [NC]
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,QSA]
--
Rik Wasmus
  Reply With Quote
Reply


Thread Tools

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT +1. The time now is 16:26.


Powered by vBulletin® ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
PHWinfo is a website Education Without Frontiers
Ad Management by RedTyger
All rights reserved
Page generated in 0.21620 seconds with 7 queries