问题
I have been working this one for a few hours now trying get this to work. I have a CodeIgniter website that use to be on an Apache server running fine. I was using the Apache URL Rewriter for the URL in order to hide the index.php. For some reason I cannot get this to work on IIS. I have Googled it and came up with several different options but some either didn't work or redirected me to my root directory.
I am trying to rewrite the URL like so
http://domain.com/v2.3.1/index.php/test
Below is my rule from the web.config
file:
<rewrite>
<rules>
<rule name="Clean URL" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
The current configuration will send me back to my root directory. My website is located at an example URL below:
http://domain/v2.3.1
- This will bring me to my main page
however
http://domain/v2.3.1/test
- Will take me back to http://domain
but the URL never changes from http://domain/v2.3.1/test
回答1:
Nothing changed on the rule. I had the rule in the wrong directory. The website root was not the domain root, it was in a sub directory. With IIS you need to have the web.config
in the same directory that you are wanting to rewrite the URL.
After several hours of banging my head I finally figured it out.
来源:https://stackoverflow.com/questions/14290837/iis-7-url-rewriting