URL Pattern Rewriting in IIS7

Discussion in 'Site & Server Administration' started by maclin123, Apr 21, 2013.

  1. #1
    I want to rewrite:

    http://www.domain.com/Apple-Mobile-Phones/AppleiPhone516GBBlackMobilePhone.asp
    Code (markup):
    to

    http://www.domain/apple/appleiphone516gbblack-deals.asp
    Code (markup):
    How to do that in IIS 7?
    Thanks in advance.
     
    maclin123, Apr 21, 2013 IP
  2. AmanDH

    AmanDH Well-Known Member

    Messages:
    315
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    140
    #2
    Get the microsoft rewrite module mate
    http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module
     
    AmanDH, Apr 21, 2013 IP
  3. maclin123

    maclin123 Member

    Messages:
    74
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #3
    In my server, its already installed. My question is how can i do that. I know that i have to change web.config but what's the code to do that....Anybody ?????
     
    maclin123, Apr 22, 2013 IP
  4. Markwebuk

    Markwebuk Well-Known Member

    Messages:
    1,595
    Likes Received:
    17
    Best Answers:
    2
    Trophy Points:
    113
    #4
    You'd need to use the below code in web.config

    <!--web.config url rewrite-->
    <system.webServer>
    <rewrite>
    <rules>
    <rule name="RedirectToWWW" stopProcessing="true">
    <match url=".*" ignoreCase="true" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="^domain.com$" />
    </conditions>
    <action type="Redirect" url="[URL]http://www.domain.com/{R:0}[/URL]" redirectType="Permanent" />
    </rule>
    </rules>
    </rewrite>
    </system.webServer>
    Code (markup):
    Well this is just an example code, you'd need to customize it according to your requirements.
     
    Last edited: Apr 23, 2013
    Markwebuk, Apr 23, 2013 IP
  5. maclin123

    maclin123 Member

    Messages:
    74
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #5
    Thanks for your reply but I need that customized code. I already specified my requirements in this thread, so please help me accordingly.
     
    maclin123, Apr 23, 2013 IP
  6. funkseo

    funkseo Greenhorn

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #6
    As I understand you want to replace "Apple-Mobile-Phones" with "apple" and this is easy.
    (I use Intelligencia.UrlRewriter.RewriterHttpModule)

    <rewriter>
    <rewrite url="~/apple/(.*)" to="~/Apple-Mobile-Phones/"/>
    </rewriter>


    But the second part I couldn't see a logical expression.
    AppleiPhone516GBBlackMobilePhone -> appleiphone516gbblack-deals

    Hope it helps...
     
    funkseo, Apr 24, 2013 IP
  7. maclin123

    maclin123 Member

    Messages:
    74
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #7
    Thanks for your reply. But i am using URL Rewrite Module 2.0 and it has some different format as Markwebuk mentioned.

    The second thing you mentioned that "I couldn't see a logical expression" . I think we can catch last MobilePhone.asp through some logical expression and convert it into -deals.asp


     
    maclin123, Apr 24, 2013 IP