You are not logged in.

#1 2005-11-15 11:40:55

sven
Member
Registered: 2005-02-01
Posts: 311

[SOLVED] Using mod_rewrite to make some http pages to https

I would like to have this url:

http://myhost.com/index.php?option=com_ … &Itemid=23

to become the https one.

This far I have tried this rule:

RewriteEngine On
RewriteCond %{REQUEST_URI}  ".*com_weblinks.*"
RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

Someting is wrong with my voodoo here, but I don't know what...

Offline

#2 2005-11-15 23:10:14

smoon
Member
Registered: 2005-08-22
Posts: 468
Website

Re: [SOLVED] Using mod_rewrite to make some http pages to https

This is how it works for me:

  RewriteEngine on
  RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R,L]

Offline

#3 2005-11-16 01:49:41

paperinik
Member
Registered: 2005-05-25
Posts: 46

Re: [SOLVED] Using mod_rewrite to make some http pages to https

smoon wrote:

This is how it works for me:

  RewriteEngine on
  RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R,L]

I have been meaning to know how to enable clean URLs. I use Drupal and have tried to edit .htaccess many ways (including your above) without success.

Offline

#4 2005-11-16 05:35:23

sven
Member
Registered: 2005-02-01
Posts: 311

Re: [SOLVED] Using mod_rewrite to make some http pages to https

This snippet from IBM has been working for me, too:

RewriteEngine on
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI}

and by using an extra RewriteCond %{REQUEST_URI} ^(.*administrator.*) also has worked nicely to enable ssl protection just over dirs like http://myhost.com/administrator/

It seems too much to protect the whole site - I'd like to have just parts of the sites that have certain words in their URLs or URIs.

Offline

#5 2005-11-16 11:47:10

mercy
Member
Registered: 2004-04-24
Posts: 62

Re: [SOLVED] Using mod_rewrite to make some http pages to https

go by https if its: www.example.com/test?foobar

# Activate the Rewrite engine
RewriteEngine On

# You only want to go by https if the QueryString CONTAINS foobar (after a ? in the URL)
RewriteCond %{QUERY_STRING} .*foobar.*
# he requestet /test .. so you can match on /test ... then y EXTERNAL REDIRECT him to you self but using https this time ... the Query_string automagically gets apended
RewriteRule ^/test$ https://www.example.com/test [R,L]


if you also want to change the query string you have to use a second RewriteRule with [QSA] ... QueryStringAppend ...


mfg

Offline

#6 2005-11-17 18:31:26

sven
Member
Registered: 2005-02-01
Posts: 311

Re: [SOLVED] Using mod_rewrite to make some http pages to https

Thank you all for comments! I'll try your solution soon, mercy  (now solving some other things) and let's see then how it works in my case.

Offline

#7 2005-11-23 11:58:28

sven
Member
Registered: 2005-02-01
Posts: 311

Re: [SOLVED] Using mod_rewrite to make some http pages to https

It worked nicely - I have another small problem now - I think page is only partly protected. https - url has red color at the Firefox' address bar and also the lock symbol at the bottom right is red. Would I need something else to add to this rewrite command:

RewriteEngine On
RewriteCond %{QUERY_STRING} .*com_contact.*
RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [NC,R,L]

Offline

#8 2005-11-24 08:03:58

sven
Member
Registered: 2005-02-01
Posts: 311

Re: [SOLVED] Using mod_rewrite to make some http pages to https

My new problem is images-related - got to fix the code to use dynamic urls for them like <img src="folder/image.jpg" and not static ones like <img src="http://www.mysite.com/folder/image.jpg".

Offline

Board footer

Powered by FluxBB