Koozali.org: home of the SME Server
Legacy Forums => Experienced User Forum => Topic started by: wjhobbs on August 10, 2005, 10:08:51 PM
-
I have a virtual domain (www.ssltest.imsig.ca) that I would like to have accessed only through the https protocol. A previous post tried to address the subject http://forums.contribs.org/index.php?topic=23230.msg98152#msg98152 but I was unable to get that to work.
What I have tried is a bit of a variant. I have a RewriteRule that gets generated only for the specified virtual domain. But I seem to be doing something wrong in specifying the regular expression. What I want to happen is that 'http://' gets replaced by 'https://' for any web access to this domain (ibay).
I have this as a custom template fragment for httpd.conf:
RewriteEngine on
{
return "" unless $virtualHost eq "ssltest.imsig.ca";
'RewriteRule ^http:\/\/(.*) https://$1 [L]';
}
I have tried a number of variants, but nothing seems to work. Generally what I get is the standard http: url -- as though nothing is matching the pattern and therefore no substitution is taking place.
I am open to suggestions (a) for a completely different approach and (b) for a better way to structure the RewriteRule.
Thanks for taking a look.
John
-
I found this code for apache
<VirtualHost _default_:80>
RewriteEngine on
RewriteRule ^/abc/(.*)$ https://%{SERVER_NAME}/abc/$1 [R,L]
</VirtualHost>
DIDN'T CHANGE THE {SERVER_NAME} part just the directory /abc/
You could make a custom template for httpd.conf and it should work I have tried it on my Fedora box and it worked fine
here's the link for it
http://www.akadia.com/services/apache_redirect.html
Also tried the post from DocLove http://forums.contribs.org/index.php?topic=23230.msg98152#msg98152
and it worked
-
Thanks for your suggestion. Using that as a base, this is what I ended up with and it works!
#
# RewriteRule directives for SSL Test
#
RewriteEngine on
{
return "" unless $virtualHost eq "imsig.ca" and $port ne "443";
'RewriteRule ^/ssltest/(.*)$ https://%{SERVER_NAME}/ssltest/$1 [R,L]';
}
"imsig.ca" is my primary domain name. I needed to add the $port condition because without it, the expanded code went into the 443 virtual domain as well when the template got expanded and that failed.
This does exaxtly what I want for an ibay url of the form "http://www.maindomain.ca/ibayname/" but still leaves outstanding the problem of achieving the same result for the separate virtual domain of the form "http://www.ibayname.ca"
I would really appreciate any suggestions about how to crack that one.
John
-
Not sure where you are trying to reach
http://domain.ca TO https://domain.ca
Redirect may be what you need
Redirect / https://domain.ca
when someone hits http://domain.ca which is just / then it will send them to https://domain.ca
this may help
http://httpd.apache.org/docs/1.3/misc/rewriteguide.html
-
Thank you again!
You pointed me in the right direction. I had tried something similar before, but it failed. But this was before I incorporated the $port condition. Both together seemed to do the trick.
{
return "" unless $virtualHost eq "ssltest.imsig.ca" and $port ne "443";
'RewriteRule ^/(.*)$ https://www.ssltest.imsig.ca/$1 [R,L]';
}
Now 'http://www.ssltest.imsig.ca' becomes 'https://www.ssltest.imsig.ca' just like I want it to.
Thanks for your help in working through the problem.
John