On Thu, Aug 15, 2019 at 2:54 PM Simon Funnell <simonfunn...@gmail.com> wrote: > > On Thu, 15 Aug 2019 at 01:00, Chris Cheshire <yahoono...@gmail.com> wrote: > > > On Wed, Aug 14, 2019 at 5:18 PM Simon Funnell <simonfunn...@gmail.com> > > wrote: > > > > > > On Tue, 6 Aug 2019 at 14:33, John Larsen <john.lar...@javapipe.com> > > wrote: > > > > > > > I usually handle the redirect on the webserver side and set the alias > > in > > > > server.xml to the subdomain. > > > > > > > > John Larsen > > > > > > > > > > > > > > > I have now successfully loaded the rewrite valve in the application > > > context.xml but I am getting the following error on start up: > > > java.util.regex.PatternSyntaxException > > > > > > This is the rewrite.config file: > > > > > > RewriteCond %{HTTP_HOST} !^(.*)\.domain\.org\ [NC] > > > RewriteRule ^(.*)$ https://www.domain.org/$1 [R=301,L] > > > > > > It looks like the first line is an error and I don't know enough about > > > regex to fix it. > > > > > > Any help is great thanks. > > > > > > > > > > The \ after .org is misplaced (it's trying to quote the space > > following it), remove that and try again > > > > Chris > > > > > > Chris > > > > > It kind of works now but when it redirects it adds two slashes to the end > of domain: > > https://www.domain.org// > > which is causing an internal server error for the URL not br normalised > > >
That's odd. I do the inverse of that to remove www and have a naked domain, but using mod_rewrite in httpd. The rewrite rule is otherwise the same. I thought the syntax was the same. Maybe something inside tomcat is forcing a / at the end of the domain for canonicalization, and then the extra / is getting added by the rewrite valve rule? Looking at a different server where I force the www, I have this instead : RewriteRule ^/(.*) https://www.domain.com%{REQUEST_URI} [L,R=301] You can try this instead. It won't be putting a / in there unless it is already present in the uri passed (unlike the other version where a / will be appended even if the uri is blank) HTH, Chris > > > > > > > > > > > > > On Tue, Aug 6, 2019 at 7:11 AM Simon Funnell <simonfunn...@gmail.com> > > > > wrote: > > > > > > > > > Hi, > > > > > > > > > > I was going to do a redirect at my dns provider from the naked > > domain to > > > > > the www subdomain. Unfortunatly this doesn't really work if it is > > over > > > > > https so I am going to have to do the redirect at the host level. My > > > > > question is, is this what the rewrite valve is for? I was going to > > set up > > > > > two hosts, one for the naked domain and one for the subdomain with a > > set > > > > up > > > > > like the following: > > > > > > > > > > <Host name="domain.org" appBase="webapps2" > > > > > unpackWARs="true" autoDeploy="true"> > > > > > <!-- Insert rewrite valve here --> > > > > > </Host> > > > > > > > > > > <Host name="www.domain.org" appBase="webapps" > > > > > unpackWARs="true" autoDeploy="true"> > > > > > > > > > > <!-- Access log processes all example. > > > > > Documentation at: /docs/config/valve.html > > > > > Note: The pattern used is equivalent to using > > > > pattern="common" > > > > > --> > > > > > <Valve className="org.apache.catalina.valves.AccessLogValve" > > > > > directory="logs" > > > > > prefix="localhost_access_log" suffix=".txt" > > > > > pattern="%h %l %u %t "%r" %s %b" /> > > > > > > > > > > </Host> > > > > > > > > > > If this is what the rewrite valve is for, how do I configure it to > > > > redirect > > > > > to the subdomain apart from when it accesses the .well-known folder > > > > (which > > > > > is needed to get a letsencrypt certificate). > > > > > > > > > > If the rewrite valve is not the correct way to do this do I just > > deploy a > > > > > catch all servlet or a filter to do the redirect instead? > > > > > > > > > > Thanks, > > > > > > > > > > Simon > > > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > > For additional commands, e-mail: users-h...@tomcat.apache.org > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org