Jump to content

Prestashop 1.5.4.1 Friendly URL Rewrite IIS7


Recommended Posts

Hey everyone!

 

I'm pretty new with Prestashop. I just downloaded 1.5.4.1 and I'm on a Windows 2008 R2 server, running IIS7 and I already have the URL Rewrite module added.

 

I've been searching for days and days now to solve this and I've got about half of it done. At first I was having an issue with images not showing on the product page, but I fixed that. Now, all of the 'pages' won't work. The URLs that go to website.com/<something>, index.php?controller=<something> when it's not a friendly URL, don't work - like /contact, /my-account, /authenticate, /sitemap, etc.

 

This is my web.config file, the rewrite section, now. It doesn't seem like the first rule ever works? When I test the rule in IIS, though, it works as expected. The product and image rules work, so I can't figure out why the 'pages' won't work.

 

<rewrite>
		<rules>
			<clear />
			<rule name="Imported Rule 1" enabled="true" stopProcessing="true">
				<match url="^.+/([a-zA-Z]+(?:[-][a-zA-Z]+)?)$" />
				<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
				</conditions>
				<action type="Rewrite" url="index.php?controller={R:1}" />
			</rule>
			<rule name="Imported Rule 1-1-1" enabled="true" stopProcessing="true">
				<match url="^([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$" ignoreCase="true" />
				<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
					<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
				</conditions>
				<action type="Rewrite" url="index.php?controller=product?id_product={R:2}" appendQueryString="true" />
			</rule>
			<rule name="Imported Rule 4-1" enabled="true" stopProcessing="true">
				<match url="content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" ignoreCase="true" />
				<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
				<action type="Rewrite" url="index.php?controller=cms&id_cms={R:1}" appendQueryString="true" />
			</rule>
			<rule name="Imported Rule 1-4" enabled="true" stopProcessing="true">
				<match url="([0-9])([0-9])\-([a-zA-Z]*_*[a-zA-Z]*)/([a-zA-Z]*-[a-zA-Z]*)\.jpg$" ignoreCase="true" />
				<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
				<action type="Redirect" url="img/p/{R:1}/{R:2}/{R:1}{R:2}-{R:3}.jpg" logRewrittenUrl="false" />
			</rule>
		</rules>
	</rewrite>

Edited by TJNevis (see edit history)
Link to comment
Share on other sites

  • 1 month later...

Hi

 

Not sure how you are getting on with this problem but I have the same system as you (Windows 2008 and IIS 7). At the moment I have gone with trying to use Helicon Ape, a free app, to give me friendly URL re-writes. Not having a lot of success at the moment but I have only just started.

 

Going by some of the blogs I have read the Microsoft offering is not fully compatible.

 

Installation of the Helicon product looks easy but I do not seem to have it visible in IIS 7 but the application is running fine.

 

If you have not been able to solve your problem I suggest you look at this product.

 

Best of luck

Geoff

Edited by JerseyG (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

Helicon ape is working fine. Free edition supports 3 sites. Just install it, and you are ready to go.
What i have achieved so far?

Everything works except the ajax cart's animation . You can disable it from the relevant module (basket block) and you are good to go.

 

 

You can also use only the native rewrite engine of iis 7.5 and still works fine. What i am using in my web.config for 1.5.4.1:

 

<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>
 

 

One more thing ,

if you are using in your urls latin accented chars or non latin chars (i.e. greek, portuguese) , you must consider adding a fix plus a registry entry for fastcgi in IIS 7.5.

http://support.microsoft.com/kb/2277918

 

Funny thing is that the update won't be installed in 2008 R2 for some reason (at least that was the case in my system, "update is not applicable" says)

 

You can go only with the registry entry:

reg add HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\w3svc\Parameters /v FastCGIUtf8ServerVariables /t REG_MULTI_SZ /d REQUEST_URI\0PATH_INFO

restart IIS and it works fine.

 

I insist if someone use the above, first thing is to test again and again because at the moment i am writing this post, i am still testing.

 

 

Link to comment
Share on other sites

  • 9 months later...

Hi, I solved your problem by adding below codes:

 

<rule name="wordpress" patternSyntax="Wildcard">
<match url="*"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php"/>
</rule>
 
as you see, I used wordpress sample!
 
but for images, I added below rule:
 
 
<rule name="Prestashop Images">
<match url="^(\d*)\-((\w+_?)+)/((\w+_?)+)\.jpg$" />
<action type="Rewrite" url="img/p/{R:1}/{R:1}-{R:2}.jpg" />
</rule>
Link to comment
Share on other sites

×
×
  • Create New...