Re: Redirecting a naked domain to sub domain
On Thu, 15 Aug 2019 at 23:30, Chris Cheshire wrote: > On Thu, Aug 15, 2019 at 2:54 PM Simon Funnell > wrote: > > > > On Thu, 15 Aug 2019 at 01:00, Chris Cheshire > wrote: > > > > > On Wed, Aug 14, 2019 at 5:18 PM Simon Funnell > > > wrote: > > > > > > > > On Tue, 6 Aug 2019 at 14:33, John Larsen > > > 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] > This works properly, thanks! > > 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: > > > > > > > > > > > > > > > > > unpackWARs="true" autoDeploy="true"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > unpackWARs="true" autoDeploy="true"> > > > > > > > > > > > > > > > > > > className="org.apache.catalina.valves.AccessLogValve" > > > > > > directory="logs" > > > > > >prefix="localhost_access_log" suffix=".txt" > > > > > >pattern="%h %l %u %t "%r" %s %b" /> > > > > > > > > > > > > > > > > > > > > > > > > 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 > >
Re: Redirecting a naked domain to sub domain
On Thu, Aug 15, 2019 at 2:54 PM Simon Funnell wrote: > > On Thu, 15 Aug 2019 at 01:00, Chris Cheshire wrote: > > > On Wed, Aug 14, 2019 at 5:18 PM Simon Funnell > > wrote: > > > > > > On Tue, 6 Aug 2019 at 14:33, John Larsen > > 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 > > > > 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: > > > > > > > > > > > > > > unpackWARs="true" autoDeploy="true"> > > > > > > > > > > > > > > > > > > > > > > > > unpackWARs="true" autoDeploy="true"> > > > > > > > > > > > > > > > > > > > directory="logs" > > > > >prefix="localhost_access_log" suffix=".txt" > > > > >pattern="%h %l %u %t "%r" %s %b" /> > > > > > > > > > > > > > > > > > > > > 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
Re: Redirecting a naked domain to sub domain
On Thu, 15 Aug 2019 at 01:00, Chris Cheshire wrote: > On Wed, Aug 14, 2019 at 5:18 PM Simon Funnell > wrote: > > > > On Tue, 6 Aug 2019 at 14:33, John Larsen > 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 > > > > > > > > > On Tue, Aug 6, 2019 at 7:11 AM Simon Funnell > > > 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: > > > > > > > > > > > unpackWARs="true" autoDeploy="true"> > > > > > > > > > > > > > > > > > > > unpackWARs="true" autoDeploy="true"> > > > > > > > > > > > > > > > directory="logs" > > > >prefix="localhost_access_log" suffix=".txt" > > > >pattern="%h %l %u %t "%r" %s %b" /> > > > > > > > > > > > > > > > > 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 > >
Re: Redirecting a naked domain to sub domain
On Wed, Aug 14, 2019 at 5:18 PM Simon Funnell wrote: > > On Tue, 6 Aug 2019 at 14:33, John Larsen 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 > > > > > On Tue, Aug 6, 2019 at 7:11 AM Simon Funnell > > 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: > > > > > > > > unpackWARs="true" autoDeploy="true"> > > > > > > > > > > > > > > unpackWARs="true" autoDeploy="true"> > > > > > > > > > > > directory="logs" > > >prefix="localhost_access_log" suffix=".txt" > > >pattern="%h %l %u %t "%r" %s %b" /> > > > > > > > > > > > > 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
Re: Redirecting a naked domain to sub domain
On Tue, 6 Aug 2019 at 14:33, John Larsen 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. > > On Tue, Aug 6, 2019 at 7:11 AM Simon Funnell > 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: > > > > > unpackWARs="true" autoDeploy="true"> > > > > > > > > > unpackWARs="true" autoDeploy="true"> > > > > > > > directory="logs" > >prefix="localhost_access_log" suffix=".txt" > >pattern="%h %l %u %t "%r" %s %b" /> > > > > > > > > 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 > > >
Re: Redirecting a naked domain to sub domain
I usually handle the redirect on the webserver side and set the alias in server.xml to the subdomain. John Larsen On Tue, Aug 6, 2019 at 7:11 AM Simon Funnell 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: > > unpackWARs="true" autoDeploy="true"> > > > > unpackWARs="true" autoDeploy="true"> > > > directory="logs" >prefix="localhost_access_log" suffix=".txt" >pattern="%h %l %u %t "%r" %s %b" /> > > > > 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 >
Redirecting a naked domain to sub domain
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: 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