I tried: RewriteRule ^webmail\.|/webmail https://%{SERVER_NAME}%{REQUEST_URI} [L,R] But that does not rewrite for http://webmail.domain On 02/22/2017 06:41 PM, Robert Moskowitz wrote:> Seems I left off one point in this message. > > This is to refine these rules in my Apache server. > > RewriteCond %{SERVER_PORT} !^443$ > RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] > > I only want the rewrite if the URL includes webmail as I indicate below. > > I have found that now the RewriteCond is 'recommended' to be changed to: > > RewriteCond %{SERVER_PORT} !=443 > > But I have not found how to test for a string in the URL in the > RewriteRule. > > > On 02/22/2017 10:02 AM, Robert Moskowitz wrote: >> My regexp skills are somewhere infinitesimally close to zero. I have >> never really 'gotten' them. >> >> That said, I have spent a couple hours already search for help to >> write a rewriterule that works on a string in the URL. In particular >> I want success if either of the following were provided: >> >> webmail.domain (e.g. webmail.foo.com) >> server/webmail (e.g. www.foo.com/webmail) >> >> And I have not found anything like this, nor do I know even close >> enough of regexp to recognize something like this in another expression. >> >> Thanks for the help. >> >> _______________________________________________ >> CentOS mailing list >> CentOS at centos.org >> https://lists.centos.org/mailman/listinfo/centos >> > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos >
And it won't if 'http://webmail.domain' is the actual text, the ^ says "at the start of the line" (in other words, 'webmail\.' must start in character position 1). Choices: Remove the caret and accept the consequence that all references to "webmail\." will be changed or determine how to re-write (pardon the pun) the rule to narrow the scope to (such as) ^http://webmail\. (http:// at the beginning of the line). I'm not familiar with Apache regex implementation so I can't say that it will accept the construct I supplied, hopefully someone else can speak to that. ----- Original Message ----- From: "rgm" <rgm at htt-consult.com> To: "centos" <centos at centos.org> Sent: Thursday, February 23, 2017 9:43:59 AM Subject: Re: [CentOS] help with RewriteRule regexp I tried: RewriteRule ^webmail\.|/webmail https://%{SERVER_NAME}%{REQUEST_URI} [L,R] But that does not rewrite for http://webmail.domain On 02/22/2017 06:41 PM, Robert Moskowitz wrote:> Seems I left off one point in this message. > > This is to refine these rules in my Apache server. > > RewriteCond %{SERVER_PORT} !^443$ > RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] > > I only want the rewrite if the URL includes webmail as I indicate below. > > I have found that now the RewriteCond is 'recommended' to be changed to: > > RewriteCond %{SERVER_PORT} !=443 > > But I have not found how to test for a string in the URL in the > RewriteRule. > > > On 02/22/2017 10:02 AM, Robert Moskowitz wrote: >> My regexp skills are somewhere infinitesimally close to zero. I have >> never really 'gotten' them. >> >> That said, I have spent a couple hours already search for help to >> write a rewriterule that works on a string in the URL. In particular >> I want success if either of the following were provided: >> >> webmail.domain (e.g. webmail.foo.com) >> server/webmail (e.g. www.foo.com/webmail) >> >> And I have not found anything like this, nor do I know even close >> enough of regexp to recognize something like this in another expression. >> >> Thanks for the help. >> >> _______________________________________________ >> CentOS mailing list >> CentOS at centos.org >> https://lists.centos.org/mailman/listinfo/centos >> > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos >_______________________________________________ CentOS mailing list CentOS at centos.org https://lists.centos.org/mailman/listinfo/centos
Hmmm, maybe I spoke too soon, why the second test didn't match isn't obvious to me (unless Apache regex is different from grep). ----- Original Message ----- From: "Leroy Tennison" <leroy at datavoiceint.com> To: "centos" <centos at centos.org> Sent: Thursday, February 23, 2017 10:15:54 AM Subject: Re: [CentOS] help with RewriteRule regexp And it won't if 'http://webmail.domain' is the actual text, the ^ says "at the start of the line" (in other words, 'webmail\.' must start in character position 1). Choices: Remove the caret and accept the consequence that all references to "webmail\." will be changed or determine how to re-write (pardon the pun) the rule to narrow the scope to (such as) ^http://webmail\. (http:// at the beginning of the line). I'm not familiar with Apache regex implementation so I can't say that it will accept the construct I supplied, hopefully someone else can speak to that. ----- Original Message ----- From: "rgm" <rgm at htt-consult.com> To: "centos" <centos at centos.org> Sent: Thursday, February 23, 2017 9:43:59 AM Subject: Re: [CentOS] help with RewriteRule regexp I tried: RewriteRule ^webmail\.|/webmail https://%{SERVER_NAME}%{REQUEST_URI} [L,R] But that does not rewrite for http://webmail.domain On 02/22/2017 06:41 PM, Robert Moskowitz wrote:> Seems I left off one point in this message. > > This is to refine these rules in my Apache server. > > RewriteCond %{SERVER_PORT} !^443$ > RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] > > I only want the rewrite if the URL includes webmail as I indicate below. > > I have found that now the RewriteCond is 'recommended' to be changed to: > > RewriteCond %{SERVER_PORT} !=443 > > But I have not found how to test for a string in the URL in the > RewriteRule. > > > On 02/22/2017 10:02 AM, Robert Moskowitz wrote: >> My regexp skills are somewhere infinitesimally close to zero. I have >> never really 'gotten' them. >> >> That said, I have spent a couple hours already search for help to >> write a rewriterule that works on a string in the URL. In particular >> I want success if either of the following were provided: >> >> webmail.domain (e.g. webmail.foo.com) >> server/webmail (e.g. www.foo.com/webmail) >> >> And I have not found anything like this, nor do I know even close >> enough of regexp to recognize something like this in another expression. >> >> Thanks for the help. >> >> _______________________________________________ >> CentOS mailing list >> CentOS at centos.org >> https://lists.centos.org/mailman/listinfo/centos >> > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos >_______________________________________________ CentOS mailing list CentOS at centos.org https://lists.centos.org/mailman/listinfo/centos _______________________________________________ CentOS mailing list CentOS at centos.org https://lists.centos.org/mailman/listinfo/centos