Migrate ReWrite from .htaccess to web.config - apache

I need to migrate a site from linux (apache) to windows (iis), BUT, I had a big trouble with it:
.htaccess
RewriteEngine On
RewriteRule %{REQUEST_FILENAME} !-f
RewriteRule %{REQUEST_FILENAME} !-d
RewriteRule ^$ index.php [NC,L]
RewriteRule ^/$ index.php [NC,L]
RewriteRule ^download/(.+)$ download/$1 [NC,L]
RewriteRule ^([0-9]+)?$ index.php?c=resetPassword&m=show&id=$1 [NC,L]
RewriteRule ^([^/.]+)?$ index.php?c=$1 [NC,L]
RewriteRule ^([^/.]+)/?$ index.php?c=$1 [NC,L]
RewriteRule ^([^/.]+)/([A-z]+)?$ index.php?c=$1&m=$2 [NC,L]
RewriteRule ^([^/.]+)/([A-z]+)/?$ index.php?c=$1&m=$2 [NC,L]
RewriteRule ^([^/.]+)/([0-9]+)?$ index.php?c=$1&m=show&id=$2 [NC,L]
RewriteRule ^([^/.]+)/([0-9]+)/?$ index.php?c=$1&m=show&id=$2 [NC,L]
RewriteRule ^([^/.]+)/([A-z]+)/([0-9]+)?$ index.php?c=$1&m=$2&id=$3 [NC,L]
RewriteRule ^([^/.]+)/([A-z]+)/([0-9]+)/?$ index.php?c=$1&m=$2&id=$3 [NC,L]
When I tried to translate to IIS platform, I tried it:
<rewrite>
<rules>
<rule name="block favicon" stopProcessing="true">
<match url="favicon\.ico" />
<action type="CustomResponse" statusCode="404" subStatusCode="1"
statusReason="The requested file favicon.ico was not found"
statusDescription="The requested file favicon.ico was not found" />
</rule>
<rule name="Rule Mapping Root" stopProcessing="true">
<match url="^/" ignoreCase="false" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/" />
</conditions>
<action type="Rewrite" url="index.php"/>
</rule>
<rule name="Rule Mapping Download" stopProcessing="true">
<match url="^download/(.+)$" ignoreCase="true" />
<conditions>
<add input="{REQUEST_URI}" pattern="^download/(.+)$" />
</conditions>
<action type="Rewrite" url="download/{R:1}" appendQueryString="true" />
</rule>
<rule name="Rule Mapping Reset Pass" stopProcessing="true">
<match url="^([0-9]+)$" ignoreCase="true" />
<conditions>
<add input="{REQUEST_URI}" pattern="^([0-9]+)" />
</conditions>
<action type="Rewrite" url="index.php?c=resetPassword&m=show&id={R:1}" appendQueryString="true" />
</rule>
<rule name="Rule Mapping Index 10" stopProcessing="true">
<match url="^([^/.]+)$" ignoreCase="true" />
<conditions>
<add input="{REQUEST_URI}" pattern="^([^/.]+)$" />
</conditions>
<action type="Rewrite" url="index.php?c={R:1}" appendQueryString="true" />
</rule>
<rule name="Rule Mapping Index 11" stopProcessing="true">
<match url="^([^/.]+)/$" ignoreCase="true" />
<action type="Rewrite" url="index.php?c={R:1}" appendQueryString="true" />
</rule>
<rule name="Rule Mapping Index 20" stopProcessing="true">
<match url="^([^/.]+)/([A-z]+)$" ignoreCase="true" />
<action type="Rewrite" url="index.php?c={R:1}&m={R:2}" appendQueryString="true" />
</rule>
<rule name="Rule Mapping Index 21" stopProcessing="true">
<match url="^([^/.]+)/([A-z]+)/$" ignoreCase="true" />
<action type="Rewrite" url="index.php?c={R:1}&m={R:2}" appendQueryString="true" />
</rule>
<rule name="Rule Mapping Index 30" stopProcessing="true">
<match url="^([^/.]+)/([0-9]+)$" ignoreCase="true" />
<action type="Rewrite" url="index.php?c={R:1}&m=show&id={R:2}" appendQueryString="true" />
</rule>
<rule name="Rule Mapping Index 31" stopProcessing="true">
<match url="^([^/.]+)/([0-9]+)/$" ignoreCase="true" />
<action type="Rewrite" url="index.php?c={R:1}&m=show&id={R:2}" appendQueryString="true" />
</rule>
<rule name="Rule Mapping Index 40" stopProcessing="true">
<match url="^([^/.]+)/([A-z]+)/([0-9]+)$" ignoreCase="true" />
<action type="Rewrite" url="index.php?c={R:1}&m={R:2}&id={R:3}" appendQueryString="true" />
</rule>
<rule name="Rule Mapping Index 41" stopProcessing="true">
<match url="^([^/.]+)/([A-z]+)/([0-9]+)/$" ignoreCase="true" />
<action type="Rewrite" url="index.php?c={R:1}&m={R:2}&id={R:3}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
I tried so many combinations and I read the Microsoft's tutorial (http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference#Rule_conditions), but I couldn't understand the working for that. Now, the site is broke. Could someone help me with this translation?

Here use this in web.config I converted the rewrite to webconfig for you.
<rule name="rule 1f">
<match url="%{REQUEST_FILENAME}" />
<action type="Rewrite" url="/!-f" />
</rule>
<rule name="rule 2f">
<match url="%{REQUEST_FILENAME}" />
<action type="Rewrite" url="/!-d" />
</rule>
<rule name="rule 3f" stopProcessing="true">
<match url="^$" ignoreCase="true" />
<action type="Rewrite" url="/index.php" />
</rule>
<rule name="rule 4f" stopProcessing="true">
<match url="^/$" ignoreCase="true" />
<action type="Rewrite" url="/index.php" />
</rule>
<rule name="rule 5f" stopProcessing="true">
<match url="^download/(.+)$" ignoreCase="true" />
<action type="Rewrite" url="/download/{R:1}" />
</rule>
<rule name="rule 6f" stopProcessing="true">
<match url="^([0-9]+)?$" ignoreCase="true" />
<action type="Rewrite" url="/index.php?c=resetPassword&m=show&id={R:1}" />
</rule>
<rule name="rule 7f" stopProcessing="true">
<match url="^([^/.]+)?$" ignoreCase="true" />
<action type="Rewrite" url="/index.php?c={R:1}" />
</rule>
<rule name="rule 8f" stopProcessing="true">
<match url="^([^/.]+)/?$" ignoreCase="true" />
<action type="Rewrite" url="/index.php?c={R:1}" />
</rule>
<rule name="rule 9f" stopProcessing="true">
<match url="^([^/.]+)/([A-z]+)?$" ignoreCase="true" />
<action type="Rewrite" url="/index.php?c={R:1}&m={R:2}" />
</rule>
<rule name="rule 10f" stopProcessing="true">
<match url="^([^/.]+)/([A-z]+)/?$" ignoreCase="true" />
<action type="Rewrite" url="/index.php?c={R:1}&m={R:2}" />
</rule>
<rule name="rule 11f" stopProcessing="true">
<match url="^([^/.]+)/([0-9]+)?$" ignoreCase="true" />
<action type="Rewrite" url="/index.php?c={R:1}&m=show&id={R:2}" />
</rule>
<rule name="rule 12f" stopProcessing="true">
<match url="^([^/.]+)/([0-9]+)/?$" ignoreCase="true" />
<action type="Rewrite" url="/index.php?c={R:1}&m=show&id={R:2}" />
</rule>
<rule name="rule 13f" stopProcessing="true">
<match url="^([^/.]+)/([A-z]+)/([0-9]+)?$" ignoreCase="true" />
<action type="Rewrite" url="/index.php?c={R:1}&m={R:2}&id={R:3}" />
</rule>
<rule name="rule 14f" stopProcessing="true">
<match url="^([^/.]+)/([A-z]+)/([0-9]+)/?$" ignoreCase="true" />
<action type="Rewrite" url="/index.php?c={R:1}&m={R:2}&id={R:3}" />
</rule>

Related

Converting large web.config to .htaccess

I have googled this question but every thing is how to convert .htaccess to web.config. How can I convert WEB.CONFIG to HTACCESS? I have recently moved to xampp from IIS. I don't really know what else or where else to ask because all the others are backwards (htaccess to webconfig) ??
Code:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="false" />
</system.web>
<system.net>
<connectionManagement>
<add address="*" maxconnection="2300" />
</connectionManagement>
</system.net>
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="403" />
<error statusCode="403" responseMode="File" path="403.php" />
<remove statusCode="404" />
<error statusCode="404" responseMode="File" path="404.php" />
</httpErrors>
<rewrite>
<rules>
<rule name="Rule 1">
<match url="^habbo-imaging/badge/([^/]+)" ignoreCase="false" />
<action type="Rewrite" url="/habbo-imaging/badge.php?badge={R:1}" appendQueryString="false" />
</rule>
<rule name="Rule 2">
<match url="^habbo-imaging/avatar/([^/]+)" ignoreCase="false" />
<action type="Rewrite" url="habbo-imaging/avatarimage.php?figure={R:1}" appendQueryString="false" />
</rule>
<rule name="Rule 3">
<match url="^habbo-imaging/avatarimage/([^/]+)" ignoreCase="false" />
<action type="Rewrite" url="habbo-imaging/avatarimage.php?username={R:1}" appendQueryString="false" />
</rule>
<rule name="Rule 4">
<match url="^habbo-imaging/head/([^/]+)" ignoreCase="false" />
<action type="Rewrite" url="habbo-imaging/head.php?figure={R:1}" appendQueryString="false" />
</rule>
<rule name="Rule 5">
<match url="^gamedata/habbopages/chat/commands" ignoreCase="false" />
<action type="Rewrite" url="gamedata/habbopages/chat/commands.txt" appendQueryString="false" />
</rule>
<rule name="Rule 6">
<match url="^gamedata/habbopages/chat/options" ignoreCase="false" />
<action type="Rewrite" url="gamedata/habbopages/chat/options.txt" appendQueryString="false" />
</rule>
<rule name="Rule 7">
<match url="^gamedata/supersecret" ignoreCase="false" />
<action type="Rewrite" url="gamedata/supersecret.php" appendQueryString="true" />
</rule>
<rule name="Rule 8">
<match url="^gamedata/external_variables" ignoreCase="false" />
<action type="Rewrite" url="gamedata/external_variables.txt" appendQueryString="false" />
</rule>
<rule name="Rule 9">
<match url="^gamedata/external_flash_texts" ignoreCase="false" />
<action type="Rewrite" url="gamedata/external_flash_texts.txt" appendQueryString="false" />
</rule>
<rule name="Rule 10">
<match url="^gamedata/override/external_flash_override_texts" ignoreCase="false" />
<action type="Rewrite" url="gamedata/override/external_flash_override_texts.php" appendQueryString="false" />
</rule>
<rule name="Rule 11">
<match url="^gamedata/override/external_override_variables" ignoreCase="false" />
<action type="Rewrite" url="gamedata/override/external_override_variables.txt" appendQueryString="false" />
</rule>
<rule name="Rule 12">
<match url="^gamedata/figuredata" ignoreCase="false" />
<action type="Rewrite" url="gamedata/figuredata.xml" appendQueryString="false" />
</rule>
<rule name="Rule 13">
<match url="^gamedata/productdata" ignoreCase="false" />
<action type="Rewrite" url="gamedata/productdata.txt" appendQueryString="false" />
</rule>
<rule name="Rule 14">
<match url="^gamedata/furnidata_xml" ignoreCase="false" />
<action type="Rewrite" url="gamedata/furnidata.xml" appendQueryString="false" />
</rule>
<rule name="Rule 15">
<match url="^gamedata/habbopages/forums" ignoreCase="false" />
<action type="Rewrite" url="gamedata/habbopages/forums.txt" appendQueryString="false" />
</rule>
<rule name="API - Default">
<match url="^api/([a-zA-Z0-9_-]+)(|/)$" ignoreCase="false" />
<action type="Rewrite" url="api.php?request={R:1}" appendQueryString="false" />
</rule>
<rule name="API - Rooms">
<match url="^api/room/([0-9_-]+)(|/)$" ignoreCase="false" />
<action type="Rewrite" url="api.php?request=room&room_id={R:1}" appendQueryString="false" />
</rule>
<rule name="API - Groups">
<match url="^api/group/([0-9_-]+)(|/)$" ignoreCase="false" />
<action type="Rewrite" url="api.php?request=group&group_id={R:1}" appendQueryString="false" />
</rule>
<rule name="API - Users">
<match url="^api/user/([a-zA-Z]+)/([a-zA-Z0-9_-]+)(|/)$" ignoreCase="true" />
<action type="Rewrite" url="api.php?request=user&search_type={R:1}&value={R:2}" appendQueryString="false" />
</rule>
<rule name="API - Random Users with limit">
<match url="^api/users/([0-9]+)(|/)$" ignoreCase="false" />
<action type="Rewrite" url="api.php?request=users&amount={R:1}" appendQueryString="false" />
</rule>
<rule name="HabboPages - Dynamic">
<match url="^gamedata/habbopages/([0-9a-zA-Z]+)(|/)$" ignoreCase="false" />
<action type="Rewrite" url="gamedata/habbopages/{R:1}.txt" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Server Error in '/' Application. Access is Denied

I've got this error when I try to run the program in the localhost in my PC but when I deployed this in the server, it works perfectly fine. Here is the error in the localhost in my pc.
I just wondering why I have this problem where in fact in our last project, it works also in my localhost but I'm not the one who set up everything. I just copy and paste the implementation for the active directory in the web config.
Here is my web config codes:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-InSys-20141208093655;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-InSys-20141208093655.mdf" providerName="System.Data.SqlClient" />
<add name="petc_insysEntities" connectionString="metadata=res://*/Models.InSys_Model.csdl|res://*/Models.InSys_Model.ssdl|res://*/Models.InSys_Model.msl;provider=System.Data.SqlClient;provider connection string="data source=phpet-sql01;initial catalog=petc_insys;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" />
<authentication mode="Windows" />
<identity impersonate="false" />
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider">
<providers>
<clear />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
<authorization>
<deny users="?" />
</authorization>
<sessionState mode="InProc" />
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="itextsharp" publicKeyToken="8354ae6d2174ddca" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.5.4.0" newVersion="5.5.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="itextsharp.xmlworker" publicKeyToken="8354ae6d2174ddca" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.5.4.0" newVersion="5.5.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"></defaultConnectionFactory>
</entityFramework>
<system.net>
<mailSettings>
<smtp>
<network host="ap.smtp.lear.com" port="25" />
</smtp>
</mailSettings>
</system.net>
</configuration>
Can somebody tell me what else I need to do to resolve this problem? I've been searching for 2 days but unfortunately still not resolve.
The error says it's a server configuration issue related to permissions. You may want to open IIS Manager from the control panel and check the virtual directory settings.

session timeout configuration asp.net mvc 4

I have website with ASP.NET MVC4 which i have problem with Session Timeout.
here is my configuration in web.config file
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>
<roleManager enabled="true">
<providers>
<clear />
<add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
<add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<sessionState mode="InProc" timeout="30" />
which is working fine in my IIS. but this setting doesn't work on the remote server ( Host Provider ) and after 10 mins i have to re-login and data lost. i call them and asked for the reason and they said you have to set session time out in another place.
what i have to do? I need to keep user logged in for 30 minutes.

IIS 8 asp.net mvc HTTP Error 500.19

Hello i have just moved server, for my asp.net mvc framework. but now i get the following error message, and to be honest i do now know what is wrong?
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x80070021
Config Error This configuration section cannot be used at this
path. This happens when the section is locked at a parent level.
Locking is either by default (overrideModeDefault="Deny"), or set
explicitly by a location tag with overrideMode="Deny" or the legacy
allowOverride="false".
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="CosplayConnectionString" connectionString="Data Source=sogaard.us;Initial Catalog=NewCosplay;Integrated Security=False;Persist Security Info=True;User ID=XXXXXX;Password=XXXXXX;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="MaxImageSize" value="5242880" />
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="RouteDebugger:Enabled" value="true" />
<add key="RecaptchaPrivateKey" value="6LeAsuASAAAAAKigNk4qtA5iS_E0RPmYTcQM9U4Z" />
<add key="RecaptchaPublicKey" value="6LeAsuASAAAAAO8HMUg9HKihCMRx0s53Dazbpoag" />
</appSettings>
<system.web>
<customErrors mode="Off" />
<httpRuntime targetFramework="4.5" />
<compilation debug="true" targetFramework="4.5" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
<add namespace="Recaptcha" />
</namespaces>
</pages>
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<roleManager defaultProvider="CosplayRoleProvider" enabled="true" cacheRolesInCookie="true">
<providers>
<clear />
<add name="CosplayRoleProvider" type="Sogaard.us.Cosplay.Library.CosplayRoleProvider, Sogaard.us.Cosplay, Version=1.0.0.0, Culture=neutral" connectionStringName="DefaultConnection" applicationname="Cosplay" />
</providers>
</roleManager>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</providers>
</sessionState>
<httpModules></httpModules>
<httpHandlers></httpHandlers>
</system.web>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<modules runAllManagedModulesForAllRequests="true"></modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="RouteMagic" publicKeyToken="84b59be021aa4cee" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-0.2.2.2" newVersion="0.2.2.2" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
</configuration>

Redirecting non-www to www with RewriteRules.config

would like to redirect example.com to www.example.com and example.de to www.example.de
<rule name="CanonicalHostNameRuleCOM" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="false" pattern="^example\.com$" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:1}" redirectType="Permanent" />
</rule>
<rule name="CanonicalHostNameRuleDE" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="false" pattern="^example\.de$" />
</conditions>
<action type="Redirect" url="http://www.example.de/{R:1}" redirectType="Permanent" />
</rule>
try following for .COM & .DE
.com
<rule name="Redirect to WWW COM" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example.com$" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:0}" redirectType="Permanent" />
</rule>
.de
<rule name="Redirect to WWW DE" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example.de$" />
</conditions>
<action type="Redirect" url="http://www.example.de/{R:0}" redirectType="Permanent" />
</rule>
I hope this would help