« Previous Next »

Not Answered Thread: Url Rewrite when there are spaces

Last post 12-18-2008 7:53 AM by Rostor. 7 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (8 items)

Sort Posts:

  • 12-16-2008, 4:59 PM

    • Rostor
    • Not Ranked
    • Joined on 12-16-2008, 4:52 PM
    • Posts 5

    Url Rewrite when there are spaces

    Hello,

     I have a problem when try to make the url rewrite when there are spaces in the directory.

    I think it is better explained with the code, here my rule :

                    <rule name="RewriteUserFriendlyURL8" stopProcessing="true">
                        <match url="^([^/]+)/([^/]+)/([^/]+)/?$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="?categoria={R:1}&amp;page={R:2}&amp;prodotto={R:3}" />
                    </rule>

    If the link has no space it works ex : http://www.cmszone.com/Blogs/product/b2evolution

    If the link has spaces it doesn't work ex : http://www.cmszone.com/Boards & Forum/product/AEF Board  

    or

    http://www.cmszone.com/Collaborative/product/Group Office

    Any help is really apreciated ! :)

    Thanks,

    Renato

  • 12-17-2008, 11:00 AM In reply to

    Re: Url Rewrite when there are spaces

    Have you tried URLEncoding or escaping the spaces?

    Jeff

    Look for Wrox's new book Professional IIS 7 in your local bookstore, or order now at Amazon.com
  • 12-17-2008, 11:16 AM In reply to

    • Rostor
    • Not Ranked
    • Joined on 12-16-2008, 4:52 PM
    • Posts 5

    Re: Url Rewrite when there are spaces

     Hi Jeff,

    I change my rules from :

    ?categoria={R:1}&page={R:2}&prodotto={R:3}

    to: 

    ?categoria={UrlEncode:{R:1}}&page={R:2}&prodotto={R:3}

    and I receive a 500 internal error.

    Well ... how I can escape the spaces ?

     Thanks

    Renato

  • 12-17-2008, 1:26 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 664

    Re: Url Rewrite when there are spaces

    The original rule that you have should work here. When you say that rule does not work - does it mean that it is not executed or it results in error?

    http://ruslany.net
  • 12-17-2008, 3:30 PM In reply to

    • Rostor
    • Not Ranked
    • Joined on 12-16-2008, 4:52 PM
    • Posts 5

    Re: Url Rewrite when there are spaces

    Well ... I know that it should work but it doesn't.

    I don't understand why and I'm stopped to go live due to this problem.

     If you check the link of the menu, you can see the problem.

  • 12-17-2008, 3:49 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 664

    Re: Url Rewrite when there are spaces

    When I request http://www.cmszone.com/Boards & Forum/product/AEF Board I get redirection to http://www.cmszone.com/ . Do you have any other rewrite rules in <rewrite> section?

    http://ruslany.net
  • 12-18-2008, 1:37 AM In reply to

    • Rostor
    • Not Ranked
    • Joined on 12-16-2008, 4:52 PM
    • Posts 5

    Re: Url Rewrite when there are spaces

    Yes I have 4 rules :

    1) ?categoria={R:1}&page={R:2}&prodotto={R:3}

    2) ?page={R:1}&id={R:2}

    3) ?page={R:1}&categoria={R:2}

    4) ?page={R:1}

     Disabling the other rules doesn't change the problem.

     

  • 12-18-2008, 7:53 AM In reply to

    • Rostor
    • Not Ranked
    • Joined on 12-16-2008, 4:52 PM
    • Posts 5

    Re: Url Rewrite when there are spaces

    I spent more times to understand the problem.

    So the space is not space but the invisible alt+255 used by the developer in php.

    Then the problem could be special ASCII charset but after installing the patch nothing change.

    Then the php developer used mbstring to change the encoding from UTF-8 to ISO-8859-1 now a part of the menu works with the rewrite rules but when i have & it still doesn't work.

    Is it possible on IIS7 to change directly the encoding to ISO ?

Page 1 of 1 (8 items)
Microsoft Communities