I've searched similar question but i didn't find an answer to my specific problem.
I'm not good with regexp or rewrites so maybe what i want to do cannot be done.
I switched a site from http to https, and redirected all http requests to the relative https using the following rule, works perfectly.
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
I also own www.mysite.it redirected through dns to www.mysite.com.
With the actived rewrite the requests get redirected to https://www.mysite.it, i don't have an ssl certificate for that and so it fails.
I would like to redirect the
http://www.mysite.it/whatever
requests to
https://www.mysite.com/whatever
The only other solution i can i find is to buy an ssl for the other domain but, being only a redirect, seems like a waste of money.
Thanks in advance for your help.
You could just hard code the url...
<action type="Redirect" url="https://www.name.com/{R:1}" redirectType="Permanent" />
Related
I tried almost all upvoted suggestions related to web.config changes for http to https redirection. Best way in asp.net to force https for an entire site?
But it's not working for me for my ASP.net site. I use GoDaddy shared hosting and have multiple sites in my account. I have ssl enabled only for one website and have to add it to filter so that other sites in the same account are not redirected to https. Here's my web.config:
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true" enabled="true">
<match url="singledomain.*" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
I can access the site currently by both http and https. But it never redirects from http to https. Is the match condition correct, and if it is, what else could be the problem?
Found the solution here: https://stackoverflow.com/a/17066105/2535756
Posting the code here which worked:
<rewrite>
<rules>
<rule name="HTTP to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="(singledomain.com.*)" />
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
With GoDaddy, in my experience, there is a setting in the Plesk app that actually will force a re-direct from HTTP to HTTPS.You can find this under your IIS settings under the Directory Security Settings and checking the Require SSL/TSL box. This forces the users' browser to use HTTPS instead of HTTP.
I have read lots of articles and none of them works for my problem
I implement a web project with Asp.net and I put SSL certificate on my website. everything works fine but when I type https://www.forexample.com it confronts an error says This connection is not private but if I type https://forexample.com then it works completely fine. I do not know how should I fix it.
here is my rules in web.config to redirect
<rewrite>
<rules>
<rule name="Redirect to non-www" stopProcessing="true">
<match url="(.*)" negate="false"></match>
<action type="Redirect" url="http://forexample.com/{R:1}"></action>
<conditions>
<add input="{HTTP_HOST}" pattern="^forexample\.com$" negate="true"></add>
</conditions>
</rule>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
which it is in system.webServer .
I think I should find a way to redirect https\:www to non www
I would appreciate any help.
You need to be able to accept the request to https://www in order to perform a redirect. This means you need a certificate that can handle that subdomain. The common solution is to get a wildcard certificate so you could handle *.yourdomain.com. This would cover www and any other subdomains you wish to use in the future.
I added SSL to my website
I added rewrite rule to redirect https.
Web.config
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}"
redirectType="Permanent" />
</rule>
</rules>
</rewrite>
Now, I'am getting error :
Too Many Redirects
How can I solve this problem ?
I solved problem.
If you are using Cloudflare change option like this :
Go Cloudflare > Crypto > SSL > Full (strict)
After a few hour your problem will be solved.
I want to redirect an url from http to https if we explicitely give http in the url bar.
// I tried keeping the below code snippet in web.config
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="some url" />
</rule>
</rules>
</rewrite>
This is working fine when I tried like this in the url bar, for
example: sampledomain.com,
but this is not working when:
I explicitly give http://sampledomain.com in the url bar
I try to access directly home page of our site i.e sampledomain.com/Home
I want the solution for the above two methods.
Hope this link helps:
HTTP to HTTPS redirects on IIS 7.x and higher
I have the following rule in my web.config file. As you can see it takes all subdomains and redirects to 'www.'
I also have an HTTP module that does switching between HTTP and HTTPS on the OnPreRequestHandlerExecute event. From what I have read and understood, this occurs after the rewrite but I could be wrong.
This code actually works in Firefox, transferring to www. then HTTPS where necessary, however it doesn't work in either Chrome or IE, maintaining the HTTP scheme.
I would like to make some changes to the code below so that the scheme is carried over rather than just assume HTTP which is does at the moment.
<rewrite xdt:Transform="Insert">
<rules>
<rule name="Redirect to www">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>