I am running a tomcat server on a vps server which is having centos. My website is browsing with mydomain.com and www.mydomain.com. But I don't want to see www in my url. i.e. If I browse with www.mydomain.com, it should be redirected to mydomain.com.
For this thing, I have added Rewrite valve in my context.xml and also created rewrite.config file in /opt/apache/conf/Catalina/mydomain.com and added below rewrite rules
RewriteCond %{HTTP_HOST} ^www.mydomain.com [NC]
RewriteRule ^(.*)$ mydomain.com/$1 [L,R=301]
But it is not working. When I browse with www.mydomain.com, the url stays the same. It is not redirecting to mydomain.com
Please suggest me where I was doing wrong.