Welcome Guest, Not a member yet? Register   Sign In
IIS support
#7

Ok, I know this thread is as old as the hills and am unsure if there is another thread with the steps needed to Import mod_rewrite rules to IIS as the search function here currently isn't working for me. But I thought I would add a quick how-to for those who are not familliar with transforming Apache mod_rewrite rules from .htaccess to an IIS web.config file.

Step 1
Install the URL Rewrite module for IIS (Suggest installing this as part of a clean IIS (Web Server) Install, IF IIS is already installed, but without the URL Rewrite Module, use the Web platform Installer from Microsoft to install the module)

Step 2
Make a backup of the .htaccess file found in the /public folder

Step 3
Make a new version of .htaccess and place it in the /public folder with only these rules included:

# Redirect Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Rewrite "www.example.com -> example.com"
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to the front controller, index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]

Step 4
In IIS Manager, in the left column, navigate to the site you wish to apply these rules too.
Ie. SERVER-NAME->Sites->Configured-site

Step 5
In the IIS section of the settings, double click the URL Rewrite Module

Step 6
    A) In the right hand column, click on "Import Rules"
    B) On the "Import mod_rewrite rules" page in the configuration file box, click the ... button and navigate to the .htaccess file you created in Step 3 and click the Import button.
    C) In the "Rewrite Rules Box", you should see your rules from the .htaccess file and in the Summary below that, you should see Summary: 3 of 3 rules(s) were converted successfully. 0 rule(s) were not converted.
    D) In the right hand column, click Apply and your rules will be written to the web.config file, and your done.

    Note: If there is an error, the Apply button will be shaded and unclickable.

Hope this helps out.
Reply


Messages In This Thread
IIS support - by ibraheem_ghazi - 07-25-2016, 05:51 PM
RE: IIS support - by kilishan - 07-25-2016, 07:56 PM
RE: IIS support - by ibraheem_ghazi - 07-25-2016, 08:28 PM
RE: IIS support - by ciadmin - 07-25-2016, 10:00 PM
RE: IIS support - by ibraheem_ghazi - 07-26-2016, 12:57 AM
RE: IIS support - by mightyted - 06-06-2019, 09:03 AM
RE: IIS support - by stlake2011 - 05-31-2021, 07:00 AM
RE: IIS support - by timexpeachtree - 09-01-2021, 02:15 AM



Theme © iAndrew 2016 - Forum software by © MyBB