question

KeesHenzen-4960 avatar image
0 Votes"
KeesHenzen-4960 asked SamWu-MSFT answered

IIS URL rewrite with special characters in the URL; how to write the rule for that

Hi, I am using the IIS 10 version and want to get rid of an old INTELLIGENCE URL rewriter and simply fall back to the normal rewrite within IIS and define my rules in the web.config.

What already is working now is this rule:

 <rewrite>
   <rules>
     <rule name="Rewrite product details.aspx">
       <match url="^([_0-9a-z-]+)/([0-9]+)/product-details.aspx" />
       <action type="Rewrite" url="product-details.aspx?productid={R:2}" appendQueryString="false" />
     </rule>
   </rules>
 </rewrite>

The url is build SEO friendly, so the url customers see are: https://www.example.com/product-name/1327/product-details.aspx

This is now rewritten into https://www.example.com/product-details.aspx?productid=1327 because I only need the second database key 1327 in this example.

But many of the products in the database have funny names like "Déjà-Blu" or german umlauts (Ü) and other diacritical characters.

This exampe https://www.example.com/Déjà-Blu/1327/product-details.aspx simply gives the error that the source can not be found!

How can I change this rule and process these special characters?




windows-server-iis
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SamWu-MSFT avatar image
0 Votes"
SamWu-MSFT answered

Hi @KeesHenzen-4960


You only need to encode your special characters, and then url rewrite, about how to encode special characters, you can refer to this link: https://www.urlencoder.org.

such as: 129744-capture.png




If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



capture.png (13.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.