Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
    
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 0:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.