1

I've started to host my own site on IIS and it was previously hosted on DreamHost on Apache so I have an .htaccess file with rewrite rules I would like to convert to the URL Rewrite module rules.

# initialize mod_rewrite
RewriteEngine on
RewriteBase /

# remove the www from the url
# RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
# RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

###  BEGIN GENERATED REWRITE RULES  ####

RewriteCond %{REQUEST_FILENAME}/index.html -f
RewriteRule ^(.*) $1/index.html

####  END GENERATED REWRITE RULES  ####

# listing pages whose names are the same as their enclosing folder's
RewriteCond %{REQUEST_FILENAME}/$1.html -f
RewriteRule ^([^/]*)/$ %{REQUEST_FILENAME}/$1.html

# regular pages
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^.*$ %{REQUEST_FILENAME}.html

# set our custom 404 page
ErrorDocument 404 /404.html

I'm using the application Hyde to generate my static site, so would like to get this working if possible. I've tried importing the htaccess but the rules do not seem to give the right outcome.

Tom Bell
  • 115
  • 5

1 Answers1

0

If you want to just dump your .htaccess into your root folder and have IIS obey your rewrite rules, there's a plugin called ISAPI Rewrite. We use the paid version but the free version should do you just fine if it's just one website.

The IIS7 rewrite syntax is (obviously) totally different, and I don't know if any tools exist.

Mark Henderson
  • 68,823
  • 31
  • 180
  • 259
  • I think I may have installed/setup wrong, but it's not working for my rewrite rules. Was there anything I would need to do after installing the MSI? – Tom Bell Sep 25 '10 at 21:51
  • I believe the paid version and the free version are a bit different regarding the placement of the `.htaccess` file - check the documentation to see if your file is in the right place. From memory the paid version can have per-site `.htaccess` whereas the free version has one file for the entire server, stored in a different location... – Mark Henderson Sep 25 '10 at 22:47
  • Didn't work with my .htaccess, so I think the best solution would be for me to work out the rules and convert them to URL Rewrite 2.0 – Tom Bell Sep 26 '10 at 00:48