web.config: Prestashop URL rewrite

To apply the URL rewrite for Prestashop the following steps are necessary.
  1. Login to your Prestashop Admin and then go to Preferences->SEO & URLs Then you can check Yes next to Friendly URL.
    web.config: Prestashop URL rewrite


    web.config: Prestashop URL rewrite


  2. Copy and paste the following code into your web.config file. Replace the entire contents of the file.
    Delete your .htaccess file then the Friendly URLs will work.


xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^api/?(.*)$" ignoreCase="false" />
<action type="Rewrite" url="webservice/dispatcher.php?url={R:1}" appendQueryString="true" />
rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^([a-z0-9]+)-([a-z0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$" ignoreCase="false" />
<action type="Rewrite" url="img/p/{R:1}-{R:2}{R:3}{R:4}.jpg" />
rule>
<rule name="Imported Rule 3" stopProcessing="true">
<match url="^([0-9]+)-([0-9]+)(-[0-9]+)?/.+.jpg$" ignoreCase="false" />
<action type="Rewrite" url="img/p/{R:1}-{R:2}{R:3}.jpg" />
rule>
<rule name="Imported Rule 4" stopProcessing="true">
<match url="^([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$" ignoreCase="false" />
<action type="Rewrite" url="img/p/{R:1}/{R:1}{R:2}{R:3}.jpg" />
rule>
<rule name="Imported Rule 5" stopProcessing="true">
<match url="^([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$" ignoreCase="false" />
<action type="Rewrite" url="img/p/{R:1}/{R:2}/{R:1}{R:2}{R:3}{R:4}.jpg" />
rule>
<rule name="Imported Rule 6" stopProcessing="true">
<match url="^([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$" ignoreCase="false" />
<action type="Rewrite" url="img/p/{R:1}/{R:2}/{R:3}/{R:1}{R:2}{R:3}{R:4}{R:5}.jpg" />
rule>
<rule name="Imported Rule 7" stopProcessing="true">
<match url="^([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$" ignoreCase="false" />
<action type="Rewrite" url="img/p/{R:1}/{R:2}/{R:3}/{R:4}/{R:1}{R:2}{R:3}{R:4}{R:5}{R:6}.jpg" />
rule>
<rule name="Imported Rule 8" stopProcessing="true">
<match url="^([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$" ignoreCase="false" />
<action type="Rewrite" url="img/p/{R:1}/{R:2}/{R:3}/{R:4}/{R:5}/{R:1}{R:2}{R:3}{R:4}{R:5}{R:6}{R:7}.jpg" />
rule>
<rule name="Imported Rule 9" stopProcessing="true">
<match url="^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$" ignoreCase="false" />
<action type="Rewrite" url="img/p/{R:1}/{R:2}/{R:3}/{R:4}/{R:5}/{R:6}/{R:1}{R:2}{R:3}{R:4}{R:5}{R:6}{R:7}{R:8}.jpg" />
rule>
<rule name="Imported Rule 10" stopProcessing="true">
<match url="^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$" ignoreCase="false" />
<action type="Rewrite" url="img/p/{R:1}/{R:2}/{R:3}/{R:4}/{R:5}/{R:6}/{R:7}/{R:1}{R:2}{R:3}{R:4}{R:5}{R:6}{R:7}{R:8}{R:9}.jpg" />
rule>
<rule name="Imported Rule 11" stopProcessing="true">
<match url="^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$" ignoreCase="false" />
<action type="Rewrite" url="img/p/{R:1}/{R:2}/{R:3}/{R:4}/{R:5}/{R:6}/{R:7}/{R:8}/{R:1}{R:2}{R:3}{R:4}{R:5}{R:6}{R:7}{R:8}{R:9}{R:1}0.jpg" />
rule>
<rule name="Imported Rule 12" stopProcessing="true">
<match url="^c/([0-9]+)(-[_a-zA-Z0-9-.*]*)(-[0-9]+)?/.+.jpg$" ignoreCase="false" />
<action type="Rewrite" url="img/c/{R:1}{R:2}{R:3}.jpg" />
rule>
<rule name="Imported Rule 13" stopProcessing="true">
<match url="^c/([a-zA-Z-]+)(-[0-9]+)?/.+.jpg$" ignoreCase="false" />
<action type="Rewrite" url="img/c/{R:1}{R:2}.jpg" />
rule>
<rule name="Imported Rule 14" stopProcessing="true">
<match url="^.*$" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="" ignoreCase="false" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" pattern="" ignoreCase="false" />
conditions>
<action type="None" />
rule>
<rule name="Imported Rule 15" stopProcessing="true">
<match url="^.*$" />
<action type="Rewrite" url="index.php" />
rule>
rules>
rewrite>
system.webServer>
configuration>