Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

URL Rewriting for IIS 7.5

Question for Randy Hoyt , I am using IIS 7.5 as my server and using the default IIS manager for running my PHP code. Up to to the URL rewritting, I had no problem rendering the web pages created for the "Enhancing a Simple PHP Application" but once I started the URL rewriting section my problems started. Thankfully, I figured out how to import the .htaccess file into the "Url Rewrite" program in IIS Manager. But after I did the code in the "Seperating Concerns: Views" video located in the "Refactoring the Codebase", I got this error:

http://bit.ly/17i9yu0

Here is the web.config file that was configured by IIS when I imported the .htaccess file

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                 <rule name="Imported Rule 1">
                    <match url="^shirts/$" ignoreCase="false" />
                    <action type="Rewrite" url="/shirts/shirts.php" />
                </rule>
                <rule name="Imported Rule 2">
                    <match url="^shirts/([0-9]+)/$" ignoreCase="false" />
                    <action type="Rewrite" url="/shirts/shirt.php?id={R:1}" appendQueryString="false" />
                </rule>
                <rule name="Imported Rule 3">
                    <match url="^receipt.php$" ignoreCase="false" />
                    <action type="Redirect" url="/receipt/" redirectType="Permanent" />
                </rule>
                <rule name="Imported Rule 4">
                    <match url="^contact.php$" ignoreCase="false" />
                    <action type="Redirect" url="/contact/" redirectType="Permanent" />
                </rule>
                <rule name="Imported Rule 5">
                    <match url="^shirts.php$" ignoreCase="false" />
                    <action type="Redirect" url="/shirts/" redirectType="Permanent" />
               </rule>
                <rule name="Imported Rule 6">
                    <match url="^(shirts/[0-9]+)$" ignoreCase="false" />
                    <action type="Redirect" url="/{R:1}/" redirectType="Permanent" />
               </rule>
               <rule name="Imported Rule 7">
                   <match url="^shirt.php$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                       <add input="{QUERY_STRING}" pattern="^id=([0-9]+)$" ignoreCase="false" />
                   </conditions>

<action type="Redirect" url="/shirts/{C:1}/?" appendQueryString="false"  redirectType="Permanent" />
               </rule>
            </rules>
        </rewrite>
   </system.webServer>
  </configuration>

When I delete the .htaccess file and the web.config, I can go to the index page without any problems, but once I try to go to the shirt pages I get the same error I do when the pages are active. I am unsure of what to do, I would greatly appreciate it if someone helped me out. :)

Thanks!