Domain Remapping from .org to .com

26 views
Skip to first unread message

mahesh

unread,
Oct 30, 2009, 9:37:24 AM10/30/09
to UrlRewrite
Hi,

when i type

http://example.org/ or http://www.example.org/ then it has to
redirect to http://www.example.com/

I written the below rule in urlrewrite.xml

<rule>
<name>Domain Remapping example.org</name>
<condition name="host" operator="equal">example.org</condition>
<condition name="host" operator="notequal">^$</condition>
<from>^/(.*)</from>
<to last="true" type="permanent-redirect">http://www.example.com/
$1</to>
</rule>

Could you please let me know whether the above rule will work for
domain remapping.


Thanks,
Mahesh.

mahesh

unread,
Oct 30, 2009, 3:13:37 PM10/30/09
to UrlRewrite
hi,

Basically i need to redirect www and non-www url to www
e.g..
http://www.example.org/
http://example.org/

To http://www.example.com/

Please advice me that this urlrewrite.xml rule is sufficient.

<rule>
<name>Domain Remapping example.org</name>
<condition name="host" operator="equal">example.org</condition>
<condition name="host" operator="notequal">^$</condition>
<from>^/(.*)</from>
<to last="true" type="permanent-redirect">http://www.example.com/
$1</to>
</rule>

Please help me out as soon as possible as i can't test it in local
host this scenario.
Regards,
Mahesh

On Oct 30, 9:37 am, mahesh <hariprasad.kanamarlap...@gmail.com> wrote:
> Hi,
>
> when i type
>
> http://example.org/ or http://www.example.org/then it has to

Avlesh Singh

unread,
Nov 1, 2009, 12:00:59 AM11/1/09
to urlre...@googlegroups.com
Multiple condition tags are "and'ed" while evaluating the rule. For your use-case, the underneath should suffice
<rule>
  <condition name="host" operator="equal" next="or">www.example.org</condition>
  <condition name="host" operator="equal">example.org</condition>
  <from>(.*)</from>
  <to last="true" type="permanent-redirect">http://www.example.com$1</to>
</rule>

Cheers
Avlesh

mahesh

unread,
Nov 2, 2009, 4:43:55 AM11/2/09
to UrlRewrite
Hi,

Thanks AKR, but the below rules were correct or not to achieve the
same(to redirect www and non-www url to www).

<rule>
<name>Domain Remapping www.example.com</name>
<condition name="host" operator="equal">www.example.org</
condition>
<condition name="host" operator="notequal">^$</condition>
<from>^/(.*)</from>
<to last="true" type="permanent-redirect">http://www.example.com/
$1</to>
</rule>

<rule>
<name>Domain Remapping example.com</name>
<condition name="host" operator="equal">example.org</condition>
<condition name="host" operator="notequal">^$</condition>
<from>^/(.*)</from>
<to last="true" type="permanent-redirect">http://www.example.com/
$1</to>
</rule>

Please let me know ASAP.

Regards,
Mahesh

On Oct 31, 11:00 pm, Avlesh Singh <avl...@gmail.com> wrote:
> Multiple condition tags are "and'ed" while evaluating the rule. For your
> use-case, the underneath should suffice
> <rule>
>   <condition name="host" operator="equal" next="or">www.example.org
> </condition>
>   <condition name="host" operator="equal">example.org</condition>
>   <from>(.*)</from>
>   <to last="true" type="permanent-redirect">http://www.example.com$1</to>
> </rule>
>
> Cheers
> Avlesh
>
> On Sat, Oct 31, 2009 at 12:43 AM, mahesh <hariprasad.kanamarlap...@gmail.com
>
> > wrote:
>
> > hi,
>
> > Basically i need to redirect www and non-www url to www
> > e.g..
> >http://www.example.org/
> >http://example.org/
>
> > To    http://www.example.com/
>
> > Please advice me that this urlrewrite.xml rule is sufficient.
>
> >  <rule>
> >     <name>Domain Remapping example.org</name>
> >     <condition name="host" operator="equal">example.org</condition>
> >     <condition name="host" operator="notequal">^$</condition>
> >     <from>^/(.*)</from>
> >     <to last="true" type="permanent-redirect">http://www.example.com/
> > $1</to>
> >  </rule>
>
> > Please help me out as soon as possible as i can't test it in local
> > host this scenario.
> > Regards,
> > Mahesh
>
> > On Oct 30, 9:37 am, mahesh <hariprasad.kanamarlap...@gmail.com> wrote:
> > > Hi,
>
> > > when i type
>
> > >http://example.org/orhttp://www.example.org/thenit has to

Avlesh Singh

unread,
Nov 2, 2009, 5:07:24 AM11/2/09
to urlre...@googlegroups.com
Thanks AKR
I tried really hard, but failed to understand the acronym!

but the below rules were correct or not  to achieve the same(to redirect www and non-www url to www).
<condition name="host" operator="equal">www.example.org</condition>

<condition name="host" operator="notequal">^$</condition>
...
I don't think you would achieve what you want with these conditions. What makes you think that <condition name="host" operator="notequal">^$</condition> would NOT match anything under the sun? It is rule which essentially says "when the host is NOT equal to an empty string". Read the previous statement once more, and you would realize that it is true for all requests (because every request has a host header). As I earlier said, multiple <condition>'s are AND'ed with other, so in effect your rule only applies to requests from www.example.org domain.
Did I make it clear?


Please let me know ASAP.
Your urgency is understood and respected. Queries on this mailing list don't go unanswered. Don't get impatient.

Cheers
Avlesh

mahesh

unread,
Nov 2, 2009, 5:49:34 AM11/2/09
to UrlRewrite
Hi,

Thank you so much for your quick reply.

i run the same in localhost and it was working fine with the below
condition

<condition name="host" operator="notequal">^$</condition>

when we enter some thing in the host and then checks the condition
like
http header!= " " and so the condition is always became TRUE.

here is a log-

[10/5/09 9:20:47:092 EDT] 0000002e WebApp A SRVE0180I:
[Servlet.LOG]:
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: matched "from"
[10/5/09 9:20:47:092 EDT] 0000002e WebApp A SRVE0180I:
[Servlet.LOG]:
org.tuckey.web.filters.urlrewrite.Condition DEBUG: evaluating
"localhost:9080" against localhost:9080
[10/5/09 9:20:47:108 EDT] 0000002e WebApp A SRVE0180I:
[Servlet.LOG]:
org.tuckey.web.filters.urlrewrite.Condition DEBUG: evaluating
"localhost:9080" against ^$
[10/5/09 9:20:47:108 EDT] 0000002e WebApp A SRVE0180I:
[Servlet.LOG]:
org.tuckey.web.filters.urlrewrite.Condition DEBUG: not equal operator
in use
[10/5/09 9:20:47:108 EDT] 0000002e WebApp A SRVE0180I:
[Servlet.LOG]:
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: conditions match
[10/5/09 9:20:47:123 EDT] 0000002e WebApp A SRVE0180I:
[Servlet.LOG]:
org.tuckey.web.filters.urlrewrite.RuleExecutionOutput DEBUG: needs to
be permanentely redirected to http://www.example.com/Applcationcontext/
[10/5/09 9:20:47:483 EDT] 0000002e WebApp A SRVE0180I:
[Servlet.LOG]:
org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: rule is last

---
what i understood is , it is not a harm if we have this condition .
am i correct ?
please let me know is it a harm or not if we have this condition in
the rule. if so the below 2 rules are correct to achive(to redirect
www
and non-www url to www).

because that condition is already existed in the application and we
are just following. coming to improve, as you said this is not at all
required because always true. correct ?

You comments are so appreciated AKS.

Regards,
Mahesh.



On Nov 2, 5:07 am, Avlesh Singh <avl...@gmail.com> wrote:
> > Thanks AKR
>
> I tried really hard, but failed to understand the acronym!
>
> but the below rules were correct or not  to achieve the same(to redirect www> and non-www url to www).
> > <condition name="host" operator="equal">www.example.org</condition>
> > <condition name="host" operator="notequal">^$</condition>
> > ...
>
> I don't think you would achieve what you want with these conditions. What
> makes you think that <condition name="host"
> operator="notequal">^$</condition> would NOT match anything under the sun?
> It is rule which essentially says "*when the host is NOT equal to an empty
> string*". Read the previous statement once more, and you would realize that
> *it is true for all requests *(because every request has a host header). As
> I earlier said, multiple <condition>'s are AND'ed with other, so in effect
> your rule only applies to requests fromwww.example.orgdomain.
> Did I make it clear?
>
> Please let me know ASAP.
>
> Your urgency is understood and respected. Queries on this mailing list don't
> go unanswered. Don't get impatient.
>
> Cheers
> Avlesh
>
> On Mon, Nov 2, 2009 at 3:13 PM, mahesh
> <hariprasad.kanamarlap...@gmail.com>wrote:
>
>
>
> > Hi,
>
> > Thanks AKR, but the below rules were correct or not  to achieve the
> > same(to redirect www and non-www url to www).
>
> > <rule>
> >    <name>Domain Remappingwww.example.com</name>
> > > > >http://example.org/orhttp://www.example.org/thenithas to

Avlesh Singh

unread,
Nov 2, 2009, 5:55:36 AM11/2/09
to urlre...@googlegroups.com
because that condition is already existed in the application and we are just following. coming to improve, as you said this is not at all required because always true. correct ?
Yes, the condition (<condition name="host" operator="notequal">^$</condition>) is always true and hence not required. It should not matter whether you run your application in localhost or a named domain.

Cheers
Avlesh

mahesh

unread,
Nov 2, 2009, 6:11:57 AM11/2/09
to UrlRewrite
Hi,

Thanks a lot AKS.

so will these rules suffice to archive redirect www and non-www url to
www.

<rule>
<name>Domain Remapping www.example.com</name>
<condition name="host" operator="equal">www.example.org</
condition>
<condition name="host" operator="notequal">^$</condition>
<from>^/(.*)</from>
<to last="true" type="permanent-redirect">http://www.example.com/
$1</to>
</rule>

<rule>
<name>Domain Remapping example.com</name>
<condition name="host" operator="equal">example.org</condition>
<condition name="host" operator="notequal">^$</condition>
<from>^/(.*)</from>
<to last="true" type="permanent-redirect">http://www.example.com/
$1</to>
</rule>

Please let me know. I think i am asking so many questions. sorry for
that AKS as i can't test it production scenarios in the localhost for
urlrewrite . Once again thanks for your comments.

Regards,
Mahesh.

On Nov 2, 5:55 am, Avlesh Singh <avl...@gmail.com> wrote:
> > because that condition is already existed in the application and we are
> > just following. coming to improve, as you said this is not at all required
> > because always true. correct ?
>
> Yes, the condition (<condition name="host"
> operator="notequal">^$</condition>) is always true and hence not required.
> It should not matter whether you run your application in localhost or a
> named domain.
>
> Cheers
> Avlesh
>
> On Mon, Nov 2, 2009 at 4:19 PM, mahesh
> <hariprasad.kanamarlap...@gmail.com>wrote:
> > [10/5/09 <http://www.example.com/Applcationcontext/%0A%5B10/5/09>9:20:47:483 EDT] 0000002e WebApp        A   SRVE0180I:

Avlesh Singh

unread,
Nov 2, 2009, 6:29:42 AM11/2/09
to urlre...@googlegroups.com
so will these rules suffice to archive redirect www and non-www url to www.  
<rule>
   <name>Domain Remapping www.example.com</name>
   <condition name="host" operator="equal">www.example.org</condition>

   <condition name="host" operator="notequal">^$</condition>
   <from>^/(.*)</from>
   <to last="true" type="permanent-redirect">http://www.example.com/$1</to>

 </rule>

 <rule>
   <name>Domain Remapping example.com</name>
   <condition name="host" operator="equal">example.org</condition>
   <condition name="host" operator="notequal">^$</condition>
   <from>^/(.*)</from>
   <to last="true" type="permanent-redirect">http://www.example.com/$1</to>
 </rule>
To keep the answer simple - YES. These rules would work without glitches for you.

But, why don't you consider the one that I sent in my first response. It is a lot more cleaner and accurate. I am pasting it once more for your reference -

<rule>
    <condition name="host" operator="equal" next="or">www.example.org</condition>
    <condition name="host" operator="equal">example.org</condition>
    <from>(.*)</from>
    <to last="true" type="permanent-redirect">http://www.example.com$1</to>
</rule>

Cheers
Avlesh

mahesh

unread,
Nov 2, 2009, 11:34:25 AM11/2/09
to UrlRewrite
Hi,

Yes that is TRUE. what ever you proposed solution is the clean and
accurate but that is an existing code and we will take that this is an
improvement.

Thanks AKS !!!

Regards,
Mahesh.

On Nov 2, 6:29 am, Avlesh Singh <avl...@gmail.com> wrote:
> > so will these rules suffice to archive redirect www and non-www url to
> > www.
>
> <rule>
>
> >    <name>Domain Remappingwww.example.com</name>
> >    <condition name="host" operator="equal">www.example.org</condition>
> >    <condition name="host" operator="notequal">^$</condition>
> >    <from>^/(.*)</from>
> >    <to last="true" type="permanent-redirect">http://www.example.com/
> > $1</to>
> >  </rule>
>
> >  <rule>
> >    <name>Domain Remapping example.com</name>
> >    <condition name="host" operator="equal">example.org</condition>
> >    <condition name="host" operator="notequal">^$</condition>
> >    <from>^/(.*)</from>
> >    <to last="true" type="permanent-redirect">http://www.example.com/
> > $1</to>
> >  </rule>
>
> To keep the answer simple - YES. These rules would work without glitches for
> you.
>
> But, why don't you consider the one that I sent in my first response. It is
> a lot more cleaner and accurate. I am pasting it once more for your
> reference -
> <rule>
>     <condition name="host" operator="equal" next="or">www.example.org
> </condition>
>     <condition name="host" operator="equal">example.org</condition>
>     <from>(.*)</from>
>     <to last="true" type="permanent-redirect">http://www.example.com$1</to>
> </rule>
>
> Cheers
> Avlesh
>
> On Mon, Nov 2, 2009 at 4:41 PM, mahesh
> <hariprasad.kanamarlap...@gmail.com>wrote:
>
>
>
> > Hi,
>
> > Thanks a lot AKS.
>
> > so will these rules suffice to archive redirect www and non-www url to
> > www.
>
> > <rule>
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages