Joomal and SEF on IIS 6.0

By | August 27, 2007

This is an article about how to get Joomla and SEF working on an IIS 6.0 server, this took me a couple of days to fully work out so I hope this save someone some time. The basic Joomla SEF / SEO is relatively easy to get working but does not really give you much, what I wanted was one of the more fancy SEF components to work with IIS that gave me nice friendly URL's that meant something, on Windows Server 2003 and IIS 6.0

I almost regretted starting this but I got the results I
wanted (and I hope what you want) and I have to admit it looks much nicer than
the bog standard Joomla URL's and the basic Joomla SEF.

First, install ISAPIRewriter (IIRF = Ionics Isapi Rewrite
Filter) on the server, if you are in a hosted environment this is where it
might end for you, this is up to you to chase with your hosting provider.
Download the fileIonicIsapiRewriter-1.2.12c-bin.zip from ISAPIRewrite http://www.codeplex.com/IIRF

Install instructions are included with this component,
basically you just take the ISAPI dll and the ini file and put them in
c:\windows\system32 then install the ISAPI filter, however before restarting
IIS remove or comment out all entries in the sample ini file or weird things
will happen to your web site 🙂 Once you have a blank ini file then at a
command prompt type iisreset to stop and start IIS and associated services. The
process is explained graphically here http://joomlaoniis.com/content/view/1/3/1/1/

Then go here to download the component JoomSEF http://www.kangainternet.com/remository/joomsef.html
I was trying to get SH404sef to work but gave up as it would not work properly
with IIRF, while JoomSEF does not have all the features of SH404SEF it does
work very well with IIS. Install the component into your Joomla site.

In the Joomla Site turn on SEO, this can done in Global Configuration,
SEO, Search Engine Friendly URL's set to yes or by modifying this line in the
config file.

$mosConfig_sef = '1';

Now, at this point your site will not work properly as
the new SEO URL's will not be recognised, don't panic ! Go to where you put the
IIRF ini file and add a section like this. No spaces between any of the lines.
All my Joomla sites are in directories off the main site, so what is below
would be valid for /it

RewriteCond %{URL} ^(/component/option,com) [NC,OR]
RewriteCond %{URL} (/|\.htm|\.php|\.html|/[^.]*)$  [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /it/(.*) /it/index.php [L,U]
 

If you have more than one site, no problem, just add
another section like this

RewriteCond %{URL} ^(/component/option,com) [NC,OR]
RewriteCond %{URL} (/|\.htm|\.php|\.html|/[^.]*)$  [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /site2/(.*) /site2/index.php [L,U]

There is probably a better way to do this but what is
above works oK for me, if anyone knows a shorter way let me know. Then at this
point try your sites home page http://www.your_domain.com/site
and let it realod so have all the right URL's on your links, try clicking around
a bit and see what you get. 

Last but least, for nice 404 error handling, and this
took a bit of working out, right click the site in IIS admin, go to Properties,
Custom Errors, click 404 then press Set to Default, it will change to "Not
Found" After doing this you can use the custom 404 page in JoomSEF, to see
that working try any URL that does not exist under your site. That’s about it,
good luck.

Leave a Reply