Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Solved: IIS7 URL Rewrite

0 votes
asked Nov 14, 2010 in Q2A Core by Frank Basti

Earlier there was a post asking if Q2A works on IIS with PHP installed.  There was a comment that read it works fine other than the url rewrite portion.

This works, but you have to create a custom web.config file for the directory where Q2A is installed.  It pretty much mimics the code that the htacess file would have on an apache server.

Below is the web.config file that needs to be placed in your Q2A directory.  Also make sure you have the first option selected for your url structure in your Q2A admin.


<?xml version="1.0" encoding="UTF-8"?>
                <rule name="Question2Answer" stopProcessing="true">
                    <match url="." ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{URL}" pattern="^(.*)//(.*)$" ignoreCase="false" />
                    <action type="Redirect" url="{C:1}/{C:2}" redirectType="Permanent" />
                <rule name="Question2Answer2" stopProcessing="true">
                    <match url="^.*$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    <action type="Rewrite" url="index.php?qa-rewrite={R:0}&amp;{QUERY_STRING}" appendQueryString="false" />


commented May 11, 2012 by ScottCher
Allas, this causes server 500 errors for my IIS7 configuration running on Windows 2008R2.  What IIS / server configuration were you using that this worked on?
commented May 11, 2012 by ScottCher
Caused a crash because this REQUIRES the Query Rewrite module be installed to your IIS... http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/

3 Answers

0 votes
answered Mar 3, 2011 by Registered user 2

When i choose first option selected for url structure i get:

11111The page cannot be found

Anybody knew what problem it could be?

commented Mar 17, 2011 by banders
I get the same error "The page cannot be found", how do you fix this??
0 votes
answered Jul 7, 2011 by Kok Kheng
Bravo!!!Thanks for your tip and code, i really need it. Slove my problem one and for all. thanks (^_^)
commented Mar 4, 2012 by Anurag Srivastava
reshown Apr 4, 2013 by Anurag Srivastava
Excellent that solved my problem as well...learned programming now
0 votes
answered Jul 27, 2012 by krafttrain
It seams that this does not work with german Umlaute:

Ä, ö, ü ...
commented Nov 18, 2014 by Đặng Anh Tuấn
I have same proplem. How to fix it?