I have the domain domain.gr
.
I have setup an Apache server with mod_rewrite
and mod_jk
.
<VirtualHost *:80>
ServerName domain.gr
ServerAlias www.domain.gr
ServerAdmin "[email protected]"
DocumentRoot /var/www
<IfModule jk_module>
JkMount /myapp/* worker1
Alias /myapp "/opt/tomcat/webapps/myapp"
<Directory "/opt/tomcat/webapps/myapp">
Options Indexes FollowSymLinks
Allow from all
</Directory>
<Location "/myapp/WEB-INF/">
Deny from all
</Location>
</IfModule>
</VirtualHost>
All works fine but now i want to canonicalize the URLs.
I want when i type
domain.gr -> www.domain.gr
domain.gr/myapp -> www.domain.gr/myapp
I use the rules
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.gr [NC]
RewriteRule ^(.*)$ http://www.domain.gr$1 [L,R=301]
When i write domain.gr
it goes to www.domain.gr
, but when i write domain.gr/myapp
it doesn't go to www.domain.gr/myapp
Any idea?