Monday, September 29, 2008

Joomla! SEF URLs and IIS

Recently I was setting up a Joomla! website on a Windows server that had previously been configured. Everything installed properly and worked just fine... that is until I turned on "Search Engine Friendly URLs" in the global configuration. Here is what I did:

White Screen Solution
When I first went to the website after turning on SEF URLs all I got was a white screen. I discovered that this was caused by URLSCAN—an ISAPI filter that is applied in IIS by default. In order to get Joomla! SEF URLs to work with this, you must:

  1. Navigate to C:\WINDOWS\system32\inetsrv\urlscan\
  2. Open urlscan.ini in your preferred text editor
  3. Find AllowDotInPath=0 and change it to AllowDotInPath=1
  4. Open the command prompt and run iisreset /restart (or restart IIS however you'd like)

Since Joomla! SEF URLs are formatted as http://www.ebrentnelson.com/index.php/my-blog.html URLSCAN was preventing the second dot from existing in the URL. This reaped some havoc on the SEF functionality.

Only Displaying index.php Solution
Unfortunately after I fixed the URLSCAN issue I was still having problems with getting my links to work. Whenever I would click on a link it would take me to my front page (index.php) instead of the desired link location. Eventually I figured out that this had to do with the IIS server being configured to use php.exe instead of php5isapi.dll. I am not exactly sure why the php.exe configuration doesn't work, but I think it has to do with the method and timing of the URL/server variables being passed (if it is even passed at all). Anyway, here is how you configure IIS to use php5isapi.dll:

  1. Open IIS ManagerClick the name of your computer then click "Web Service Extensions"
  2. On the right, click the link titled "Add a new Web service extension..."
  3. Set the extension name (doesn't matter what you use)
  4. Add the php5isapi.dll to the required files (this was found at C:\PHP\php5isapi.dll in my case)
  5. Make sure Set extension status to Allowed is checked
  6. On the left, in the Web Sites folder, right click your Joomla! website, select Properties
  7. Select the Home Directory tab, click the Configuration... button under Application settings
  8. Click Add... on the Mappings tab
  9. Set the executable path to the same thing you did in step 5, set the extension to ".php", click OK
  10. Click Apply
  11. Restart IIS

With all of this done, I was able to use Joomla! SEF URLs in IIS without a problem. Please note that the server hosting this site was using IIS 6 and PHP 5. This might not be the answer in all circumstances, but if you are having SEF issues first check the URLSCAN and then your PHP configuration. Good luck!

No comments: