Related to some of my previous questions.
Now I have the setting, I really like it;
Apache httpd listens on port 80, accepting http and https connections. Multiple Tomcat instances run on multiple AJP ports.
Mod_Jk sends different URL requests to different tomcat instances;
www.mydomain.com/demo -> tomcat:8101 www.mydomain.com/test -> tomcat:8102 www.mydomain.com/ -> tomcat:8100
This is achieved using the following configuration in httpd.conf (or included subfiles);
LoadModule jk_module modules/mod_jk.so JkWorkersFile conf/workers.properties JkLogFile logs/mod_jk.log JkLogLevel info NameVirtualHost *:80 <VirtualHost *:80> JkMount /demo* demoTomcat (workers.properties not shown) JkMount /test* testTomcat JkMount /* rootTomcat </VirtualHost>
And all this works great. I also have SSL setup and work for https connections using a similar VirtualHost tag;
<VirtualHost _default_:443> JkMount /demo* demoTomcat JkMount /test* testTomcat JkMount /* rootTomcat ... SSL Stuff follows ....
I'm having problems now, because my SSL certificate is only for www.mydomain.com and NOT mydomain.com.
I am advised to use the following mod_rewrite calls:
Options +FollowSymlinks LoadModule rewrite_module modules/mod_rewrite.so RewriteEngine On RewriteCond %{HTTP_HOST} !^(www\.|$) [NC] RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [PT,L]
I placed them before and after the mod_jk rules in the httpd.conf file. Apache at first complained that RewriteEngine was an invalid command, but it was gone when I first remembered the LoadModule command :) Now Apache reboots just fine, the server starts and accepts requests, and everything works the way it is used ... but thats just that. do these mod_rewrite commands seem to have no effect?
I print http://mydomain.com in a browser and I just get my site as usual. The URL does not change to http://www.mydomain.com , and when I start accessing protected areas, I get warnings that mydomain.com NOT secure and serves me as a certificate from another site called www.mydomain.com (why this is a problem at all, and it can't just use some logic to implement its one and the same site, I don't know!).
Am I putting mod_rewrite rules in the wrong place? I read that it should work, rewriting should change the URL to www. and then go to mod_jk stuff for anything else?