SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard tgavin's Avatar
    Join Date
    Feb 2003
    Location
    FL
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mod_rewrite to IIS issue

    I'm having a weird issue on IIS with a converted mod_rewrite rule involving hyphens.

    This does NOT work: server.com/post/eie8eu/test/
    This does work: server.com/eie8eu/te-st/

    The actual URL does not contain a hyphen. I can't figure out why the server demands that the hyphen is present.

    Code:
    <rule name="View Post" stopProcessing="true">
    	<match url="^post/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$" ignoreCase="false" />
    	<action type="Rewrite" url="/post.php?post_url_id={R:1}&amp;post_url={R:2}" appendQueryString="false" />
    </rule>

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,680
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    tg,

    Sorry, that's M$ code which is typically over complex. Since this is the Apache forum, I've move your thread to the Server forum where our IIS guys hang out.

    Edit:

    Eek! Someone did it while I was responding!


    As for your code, it (the regex) appears to be fine but I'm not familiar with this syntax.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,653
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    First, the 'M$' code isn't overly complex, but rather it uses a structured format easily readable with standard libraries.

    As for the answer, I suck at regexes, but I think you need to escape that '-' as that is a control character for regexes.

  4. #4
    SitePoint Wizard tgavin's Avatar
    Join Date
    Feb 2003
    Location
    FL
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wwb_99 View Post
    As for the answer, I suck at regexes, but I think you need to escape that '-' as that is a control character for regexes.
    Thank you. That was it

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,680
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Thanks, Wyatt!

    Actually, in the Apache (original) mod_rewrite, the character range definition uses hyphens to define character ranges so it has to be either the first or last character in the definition to remove the ambiguity (FIRST is preferred). It took Wyatt (our "paid M$ Shill") to see that M$ likes to escape characters rather than rely on their positioning!

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •