Converting .htaccess (subfolder) to IsapiRewrite4.ini

Topics: Developer Forum, Project Management Forum, User Forum
Oct 5, 2008 at 1:17 PM

I am trying to move a PHP website from a Linux server to a Windows server and I'm having terrible problems converting the rewrite rules that were previously within the "accommodation/.htaccess" file to the top level  IsapiRewrite4.ini file.

Could someone please explain how I can modify the following code so that it works within the top level  IsapiRewrite4.ini file ?

#Following code was within top level .htaccess file

#AddType application/x-httpd-php5

RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com [NC]
RewriteRule (.*)$1 [R=301,L]

#Following code was within "accommodation/.htaccess

RewriteCond %{REQUEST_URI} !.*\.(php|jpg|png|jpeg|gif|ttf|sql|txt|htm|zip|css)
RewriteCond %{REQUEST_URI} !(wheelchair-access|pet-friendly)
RewriteCond %{REQUEST_URI} !/accommodation/$
RewriteCond %{REQUEST_URI} !/accommodation/.+/.*
RewriteRule (.*)$ /accommodation/listing-all.php?type[]=$1
RewriteCond %{REQUEST_URI} (.*)\.html
RewriteRule (.*)\.html$ /accommodation/listing-view.php?Title=$1
RewriteRule wheelchair-access$ /accommodation/listing-all.php?Features[]=Wheelchair+Access+or+some+disabled+facilities
RewriteRule pet-friendly$ /accommodation/listing-all.php?Features[]=Pet+Friendly

Thanks in advance

Oct 6, 2008 at 9:20 PM
Edited Oct 6, 2008 at 10:20 PM

This should get you started (ps: this works in v1.2.15 of the filter and later): 

RewriteLog C:\temp\Nick-iirf-
RewriteLogLevel 4

RewriteFilterPriority HIGH

# Redirect to the proper host if necessary
RewriteCond %{HTTP_HOST} ^(?!www\.mywebsite\.com)(.+)$ [I]
RewriteRule ^(.*)$$1 [R=301,L]

# don't rewrite any request that ends with one of these extensions RewriteRule (.+\.)(php|jpg|png|jpeg|gif|ttf|sql|txt|htm|zip|css)$ - [L] # Special case pet-friendly and wheelchair-access RewriteRule wheelchair-access$ /accommodation/listing-all.php?Features=Wheelchair+Access+or+some+disabled+facilities [L] RewriteRule pet-friendly$ /accommodation/listing-all.php?Features=Pet+Friendly [L] # any .html request gets rewritten to listing-view.php for the given Title RewriteRule ^/(.*)\.html$ /accommodation/listing-view.php?Title=$1 # anything else that does not begin with /accomodation gets rewritten to listing-all.php for the given type RewriteRule ^/(?!accommodation/)(?!accommodation/.+/.*)(.+)$ /accommodation/listing-all.php?type=$1
Oct 9, 2008 at 8:48 AM
Hi Cheeso,

Many thanks indeed for your help.

The only bit I'm struggling with now is the "listing-view" part

# any .html request gets rewritten to listing-view.php for the given Title
RewriteRule ^/(.*)\.html$ /accommodation/listing-view.php?Title=$1

The log file keeps reporting that no match was found.

An example URL is accommodation/Manor-Farm.html

Many thanks again for your help so far.
Oct 14, 2008 at 5:18 AM
I don't know why the URL you mentioned is not being matched.  I'd have to see the logfile.