|
|
| ||||||
| alt.apache.configuration Apache web server configuration issues. |
![]() |
| | Thread Tools |
| | #1 |
|
Posts: n/a Hébergeur: | 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 |
|
| | #2 |
|
Posts: n/a Hébergeur: | 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. * |
|
| | #3 |
|
Posts: n/a Hébergeur: | 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. * |
|
| | #4 |
|
Posts: n/a Hébergeur: | 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. * |
|
| | #5 |
|
Posts: n/a Hébergeur: | 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. * |
|
| | #6 |
|
Posts: n/a Hébergeur: | 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 |
|
![]() |
| Thread Tools | |
| |