we migrate our webapp hosted in a directory "webapp" inside main domain:
http://www.example.com/webapp/
To the new subdomain without "webapp" folder:
http://subdomain.example.com/
I need to redirect only subdir "webapp". I don't want to redirect other url like http://www.example.com/, http://www.example.com/folder1, http://www.example.com/folder2, ....
But we have already sent a lot of emails to customers with link inside like: LOGIN TO YOUR DASHBOARD or other link like DOWNLOAD YOUR DOC
Now i'm trying to do a redirect trough web.config but it seem that nothing work.
If I try no navigate to, for example, http://www.example.com/webapp/login i don't get redirected to http://subdomain.example.com/login/ as expected.
If I try no navigate to, for example, http://www.example.com/webapp/data/download.php/id=43 i don't get redirected to http://subdomain.example.com/data/download.php/id=43 as expected.
Any suggest?
<rule name="redirect-to-subdomain" stopProcessing="true">
<match url="^webapp/$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" url="http://subdomain.example.com/{R:0}" redirectType="Permanent" />
</rule>
You rule won't work except for http://www.example.com/webapp/.
If you want to redirect link like http://www.example.com/webapp/login. Please try this rule.
<rule name="redirect-to-subdomain" stopProcessing="true">
<match url="^webapp/(.*)$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" url="http://subdomain.example.com/{R:1}" redirectType="Temporary" />
</rule>
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)");
I'm trying to setup an IIS rewrite rule to add '.html' to URL's that don't have an extension, eg:
Original URL: www.domain.com/page
Rewrite to: www.domain.com/page.html
And I want to ignore any URL's that have an extension (eg. if they are images or other files)
Does anybody know the rule that I would need to set this up?
I worked this out myself by modifying a rule that I had on another website:
<rule name="rewrite directories to html" stopProcessing="true">
<match url="(.*[^/])$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" pattern="(.*?)\.[a-zA-Z]{1,4}$" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.html" />
</rule>
I have two URL rewrite rules. Individually they work perfectly, but when both are turned on, they are conflicting.
The first is in my root dir web.config, takes all requests to files in /seo/ and serves them by requests in the root of the website.
<rule name="RewriteToFile">
<match url="^(?!seo/)(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="seo/{R:1}" />
</rule>
The next one is in the web.config in a sub directory called /blog (it's a Wordpress blog).
<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>
Individually turned on, they work fine, but if both of them are on, the blog will only serve 403's...
Is there a way to enable both of these rules?
I am using following web.config entry for url rewriting to remove .aspx extension.
<rewrite url="~/(.+)" to="~/$1.aspx" />
The problem I am getting here is if I have any image on page, it assigns .aspx extension to image.
Also if I tried to access my site like http://exmaple.com, it get redirected to http://exmaple.com/default.aspx.aspx.
I want to know if there is any way to add ignore case in web.config.
Your rewrite should look something like this, to remove .aspx
<rewrite>
<rules>
<rule name="RewriteASPX">
<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="{R:1}.aspx" />
</rule>
</rules>
</rewrite>