IIS Rewrite not working (but redirection does)

前端 未结 4 465
孤城傲影
孤城傲影 2021-01-03 19:50

I was trying to play with URL re-writing using the Rewrite Module 2.0 but I had no luck getting it to work. What I\'m trying to do is re-write all calls to web app

4条回答
  •  爱一瞬间的悲伤
    2021-01-03 20:31

    Stumbled across this old post when I was trying to solve the same issue.

    SOLVED!

    Using Rewrite URL feature in IIS Services Manager I created a friendly URL rule.

    This worked ok and when I looked at the rule in the web.config file (www root) it showed 1 rule to redirect and 1 rule to rewrite.

    I edited this to suit 1 match. Then I just duplicated this code editing the product ID for each. Example below:

    
        
        
            
            
        
        
    
    

    The first rule looks for the string "product.php" in the URL and "id_product=35", it then redirects to "990mm-bohemia-cast-iron-electric-radiator" which currently does not exist. Then (see below)

    
        
        
            
            
        
        
    
    

    This rule rewrites the "product.php?id_product=35" bit to `990mm-bohemia-cast-iron-electric-radiator", creating the new location for the redirect.

提交回复
热议问题