Web.Config causes 500 internal server error - iis-7

This is my web.config file contents:
<?xml version="1.0"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>
</configuration>
I'm trying to use pretty permalinks of wordpress.
But this web.config files causes 500 Internal Server Error.
What is the problem?

The problem was from the server, they have not installed Microsoft URL Rewriting Module correctly...
The module has been installed correctly, and then problem solved.

The answer provided by Mahdi is correct. However, if you are unable to install the URL Rewrite module (which was the problem I had due to some signature verification problem), you can download an older version of the module from the link provided below. This ended up working for me.
Hope this helps.
https://forums.iis.net/t/1239468.aspx?URL+rewrite+installation+failing+due+to+signature+verification+failure

Related

IIS giving 0x8007000d "malformed XML" although the Web.config is valid

I am trying to use <system.webServer><rewrite> to enforce WWW but i keep getting the mentioned error "which indicates the xml is malformed" whenever I load the site.
The error is raised from the whole <rewrite> block "surrounded by comments".
I tried online web.config validator and it didn't show any errors.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<!--Enfore WWW Problem Here-->
<rewrite>
<rules>
<clear />
<rule name="WWW Rewrite" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\.(.*)$" />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
<!--Enfore WWW Problem Here-->
</system.webServer>
</configuration>

IIS URL Rewrite to querystring parameter

I need to capture requests to folders that aren't file folders to be redirected to a default page with the requested path as the querystring.
For example, if the user requests
www.mysite.com/IT
I want it to redirect to
www.mysite.com/default.aspx?q=IT
However, if they request a page that is in a real sub-folder, that shouldn't be redirected. For example, requests to www.mysite.com/projects/new.aspx shouldn't try to do any re-directions as it's a physical folder and file in the site.
Use the IIS Rewrite module and the set it up in the web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Redirector" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<add input="{PATH_INFO}" pattern="/*" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/default.aspx?q={PATH_INFO}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
You could define a 404 error page that would redirect to your default page with the "q=" that you desire

How to remove index.php from url using web.config in iis server 8.0?

I have installed wordpress in iis server version 8.0. i have added custom structure in wordpress permalinks. server is not supporting permalinks. so i created web.config to remove index.php from the url.i cant able remove index.php. In root website i have web.config file. i have created another config file to remove the index.php from the url in the sub folder. its not working. Is there any solution to remove it.
website url: http://www.cyz.com/blog/index.php/links
to
url: http://www.cyz.com/blog/links
code in blog folder:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument enabled="true">
<files>
<add value="blog/index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="WPurls" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="blog/index.php/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Adding code to web.config to hide my page extensions

I have this web.config file and i want to add a code to it that will hide the .asp of a page in my website called "users.asp" . please how do i do it
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
</system.webServer>
</configuration>
Obviously you need the URL rewrite module installed, and you need IIS7 or above, this won't work on IIS6
<rewrite>
<rules>
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url="^users/$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="users.asp" />
</rule>
</rules>
</rewrite>
Recommended reading:
http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module

Trouble using Silex framework on IIS

I am trying to configure the silex framework and just get an example application working. I am using an IIS server version 7.5 to do so. On the following website it gives me a sample web.config file I should be using. The file is as follows:
<?xml version="1.0"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Silex Front Controller" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
The problem is when trying to navigate to the website I just get the error:
The requested page cannot be accessed because the related
configuration data for the page is invalid.
So essentially IIS says the file is incorrect but I don't have much experience with these files so I don't know if there is a problem. Maybe the file is outdated and the newer doesn't work with newer versions of IIS. There is nothing in the server logs. Anyone come across this problem before?
Turns out I just needed to install the rewrite module for IIS at the following link:
http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module

Resources