Can reg ex be used in host name conditional?

View: New views
3 Messages — Rating Filter:   Alert me  

Can reg ex be used in host name conditional?

by Nicole-27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi all,

It could be my server configuration, but a rule like the following
will create a never ending redirect loop.

<rule>
    <condition name="host" operator="equal">example.com</condition>

    <from>^/(.*)$</from>
    <to type="redirect">http://www.example.com/$1</to>
</rule>

I'm attempting to redirect non-www requests to www.  However, both the
www and non-www URLs will match on the host conditional above.  Can
regular expressions be used in the host condition so that I could
specify no www (I actually tried this, but it didn't work - or my reg
ex sucked)?  Or is there a better way to do this?

The workaround I've found is to use "notequal" and specify every other
host name I _don't_ want redirected.  However, we're serving quite a
few different domains from our CMS so that list is long, and it feels
hackish.

Any suggestions?

Thanks,

--Nicole

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "UrlRewrite" group.
To post to this group, send email to urlrewrite@...
To unsubscribe from this group, send email to urlrewrite+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/urlrewrite?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Can reg ex be used in host name conditional?

by Avlesh Singh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Did you try this?
<condition name="host" operator="equal">^example.com$</condition>

Cheers
Avlesh

On Mon, Sep 28, 2009 at 7:54 AM, Nicole <nicole.swan@...> wrote:

Hi all,

It could be my server configuration, but a rule like the following
will create a never ending redirect loop.

<rule>
       <condition name="host" operator="equal">example.com</condition>

       <from>^/(.*)$</from>
       <to type="redirect">http://www.example.com/$1</to>
</rule>

I'm attempting to redirect non-www requests to www.  However, both the
www and non-www URLs will match on the host conditional above.  Can
regular expressions be used in the host condition so that I could
specify no www (I actually tried this, but it didn't work - or my reg
ex sucked)?  Or is there a better way to do this?

The workaround I've found is to use "notequal" and specify every other
host name I _don't_ want redirected.  However, we're serving quite a
few different domains from our CMS so that list is long, and it feels
hackish.

Any suggestions?

Thanks,

--Nicole




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "UrlRewrite" group.
To post to this group, send email to urlrewrite@...
To unsubscribe from this group, send email to urlrewrite+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/urlrewrite?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Can reg ex be used in host name conditional?

by Nicole-27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


That was exactly what I needed (and a big "duh" to myself on that
one). Thanks!

--Nicole

On Sep 27, 11:17 pm, Avlesh Singh <avl...@...> wrote:

> Did you try this?
> <condition name="host" operator="equal">^example.com$</condition>
>
> Cheers
> Avlesh
>
> On Mon, Sep 28, 2009 at 7:54 AM, Nicole <nicole.s...@...> wrote:
>
> > Hi all,
>
> > It could be my server configuration, but a rule like the following
> > will create a never ending redirect loop.
>
> > <rule>
> >        <condition name="host" operator="equal">example.com</condition>
>
> >        <from>^/(.*)$</from>
> >        <to type="redirect">http://www.example.com/$1</to>
> > </rule>
>
> > I'm attempting to redirect non-www requests to www.  However, both the
> > www and non-www URLs will match on the host conditional above.  Can
> > regular expressions be used in the host condition so that I could
> > specify no www (I actually tried this, but it didn't work - or my reg
> > ex sucked)?  Or is there a better way to do this?
>
> > The workaround I've found is to use "notequal" and specify every other
> > host name I _don't_ want redirected.  However, we're serving quite a
> > few different domains from our CMS so that list is long, and it feels
> > hackish.
>
> > Any suggestions?
>
> > Thanks,
>
> > --Nicole
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "UrlRewrite" group.
To post to this group, send email to urlrewrite@...
To unsubscribe from this group, send email to urlrewrite+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/urlrewrite?hl=en
-~----------~----~----~----~------~----~------~--~---