I am trying to rewrite the URL through "Using URL Rewrite Module" on IIS7 (windows 7).
URL: http://localhost/AIM/group-discussion/videos.aspx?id=4&title=some-title
Rewrite URL: http://localhost/AIM/group-discussion/videos/4/some-title
Rewrite rule:
<rewrite>
<rules>
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url="^AIM/group-discussion/videos/([^/]+)/([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="AIM/group-discussion/videos.aspx?id={R:1}&title={R:2}" />
</rule>
</rules>
</rewrite>
I am getting 404 error while accessing rewrite URL (http://localhost/AIM/group-discussion/videos/4/some-title)
following error log through "Failed request tracing" in IIS7
MODULE_SET_RESPONSE_ERROR_STATUS
ModuleName="IIS Web Core", Notification="MAP_REQUEST_HANDLER", HttpStatus="404", HttpReason="Not Found", HttpSubStatus="0", ErrorCode="The system cannot find the file specified.
(0x80070002)", ConfigExceptionInfo=""
I am running site in "Integrated Pipe mode"
Related
I have a windows server 2016 Standard.
I have SSL installed and working fine. I also add the following to URL rewrite to redirect http to https:
<rules>
<rule name="ssl redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
</rule>
</rules>
Now I added a Rule to hide my extension:
<rule name="hide .aspx ext" enabled="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}.aspx" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="{R:0}.aspx" />
</rule>
However, now, I don't get the secure symbol (the lock icon) any more and saying the site is not secure. what am I doing wrong?
Thanks for any help
URL rewrite shouldn't report this error when you just rewrite for friendly URL.Did you receive this error in Edge or chrome?
1.I notice that you are using MatchAny for your rule.Based on my understanding you should use MatchAll instead.
<rule name="hide .aspx ext" enabled="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}.aspx" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="{R:0}.aspx" />
</rule>
2.What error message did you receive when chrome report site is not secure? Did you
receive something likeNET::ERR_CERT_COMMON_NAME_INVALID ? Please open chrome F12 developer tool->Seucrity. You should be find the root cause. Please ensure your are using a valid certificate with valid domain and SAN.
3.Please ensure the http binding and https binding are hosted in differernt site. To
enable SSL, you need to enable Require SSL. Then SSL handshake will corrupt http request from same site. So you need another site to handle http request and do the redirection.
I started installing (through the Web Installer Platform) a Wordpress blog on my Windows (2012) Server.
On this server I'm already hosting a ASP.NET MVC 4.5 site.
Now, before I can proceed configuring the Wordpress site (by opening www.***.com/wp-config.php),
I seem to create a new redirect rule in IIS / web.config.
Otherwise it will give conflicts with the existing ASP.NET site.
I have tried this redirect rule:
<rule name="wordpress blog" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
<add input="{REQUEST_URI}" pattern="^/(blog)" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php"/>
</rule>
With this rule, when opening https://www.****.com/blog/wp-config.php I end up with a runtime error on https://www.****.com/blog/error?aspxerrorpath=/blog/wp-config.php
And when adding in www.***.com/wp-config.php (so in the root folder)
<rule name="block" stopProcessing="true">
<match url="^blog$" />
<action type="none" />
</rule>
and going to https://www.***.com/blog/wp-config.php, I am getting the same errorpage as above.
I can't seem to figure out how this rule should look like. Is there anyone who can help me out there?
According to your description, I suggest you could try to use belwo url rewrite rule in the asp.net application.
This rule will redirect all the request with blob to the index.php.
<rule name="wordpress blog" >
<match url="blog/(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="http://{yourdomian}/blog/index.php"/>
</rule>
It was solved by adding "blog" in the global.asax.cs in the ExclusionFilter as follows:
i18n.UrlLocalizer.QuickUrlExclusionFilter = new System.Text.RegularExpressions.Regex(#"(?:sitemap.xml|.css|.jpg|.png|.svg|.woff|.woff2|.eot|.js|.html|.json)$|(?:blog)");
We have recently created a Wordpress site which will be hosted on a Windows 2012 Server. The server is currently serving compiled code of which one of the URL's it uses is login.aspx.
When we add the Wordpress site and enable permalinks, we get the default Wordpress page instead of login.aspx.
We have unsurprisingly narrowed it down to the web.config rewrite rule.
<rewrite>
<rules>
<rule name="wordpress" patternSyntax="Wildcard">
<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"/>
</rule>
</rules>
</rewrite>
I'm sure we have to negate the login.aspx page some how but I'm not sure how to do it. This has to work as a single site for now.
All I needed to do was add in the following:
<add input="{URL}" negate="true" pattern="*.aspx" />
On my Windows 2012 server I have installed the URL Rewrite module in IIS. I have followed this guide to redirect non-www to www in web.config:
http://www.surfingsuccess.com/asp/iis-url-rewrite.html#.VF6GBid0yAU
So far, so good!
The only problem is that we also host the subdomain "api.example.com". This API stops working when I apply the code in web.config.
My question is: What is wrong with the code below? Why does the subdomain stop working when I try to redirect non-www to www, except "api.example.com"?
<rewrite>
<rules>
<rule name="CanonicalHostNameRule1">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.example\.com$" negate="true" />
<add input="{HTTP_HOST}" pattern="^api\.example\.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:1}" />
</rule>
</rules>
</rewrite>
I have similar check and I have same rule but have specified differently in pattern.
My suggestion is to enable Failed request tracing to check URL rewrites.
http://www.iis.net/learn/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules
Edit: Updated rule.
<rewrite>
<rules>
<rule name="non-root" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^(www.example.com)$" negate="true" />
<add input="{HTTP_HOST}" pattern="^(api.example.com)$" negate="true" />
<add input="{HTTP_HOST}" pattern="^(example.com)$" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:1}" />
</rule>
</rules>
</rewrite>
Actually, there was nothing wrong with my rewrite code. The reason why the API stopped working was because it had a referance to the top domain of the site (example.com), this caused a conflict with the rewrite code. After changing the referance to the www -version of the doman (www.example.com) everything worked fine.
I am getting the following error when i run my .aspx page.
Error Code0x8007000d
The configuration section 'rewrite' cannot be read because it is missing a section declaration
I have a simple v.aspx page which has the following code:
Response.Write(Request("q"))
My hosting server as IIS 7 installed with URL rewrite feature enabled (that's what they claim)
My web.config file has the following lines under :
Note: The node has blue squiggly lines under it
<rewrite>
<rules>
<rule name="RewriteUserFriendlyURL1" 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="v.aspx?q={R:1}" />
</rule>
</rules>
</rewrite>
I have searched stackoverflow but did not find a solution.
May be someone found a solution.
TIA
Make sure your <rewrite> is enclosed in the <system.webServer></system.webServer> section.
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="RewriteUserFriendlyURL1" 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="v.aspx?q={R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Install the URL Rewrite module http://www.iis.net/download/URLRewrite and that should be sorted. It fixed my problem
The rewrite section in system.webServer is supported in IIS7, but not IIS6. The error is likely caused by deploying this site to a server that's only running IIS6.