infranco
asked on
301 Redirects and Canonicalization in Tomcat 6
Tomcat 6 is acting as both our Application Server as well as our Web Server (that is, we're not using Apache/httpd).
In regular Apache, the global redirection of
http://sampledomain.com
to
http://www.sampledomain.com
can be done using the .htaccess file. Tomcat has no such file.
Does anyone have any ideas as to how non-WWW URLs should be 301 redirected to WWW URLs in Tomcat?
Thank you!
(note, in our implementation, Apache webserver is *not* running so mod_jk and mod_proxy_ajp are unavailable).
In regular Apache, the global redirection of
http://sampledomain.com
to
http://www.sampledomain.com
can be done using the .htaccess file. Tomcat has no such file.
Does anyone have any ideas as to how non-WWW URLs should be 301 redirected to WWW URLs in Tomcat?
Thank you!
(note, in our implementation, Apache webserver is *not* running so mod_jk and mod_proxy_ajp are unavailable).
*in .htaccess*
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^sampledomain.com [nc]
rewriterule ^(.*)$ http://www.sampledomain.com/$1 [r=301,nc]
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
UrlRewriteFilter looks really interesting. We'll try it out (along with caterham_www's code) and let everyone know how it works out.
Thanks!
Thanks!
and the rule in a WEB-INF/urlrewrite.xml might look like
Open in new window