0

ASP.NET 3.5, VB.NET

We have a website, e.g. hosted with an external web host.

We want to get a SSL certificate so that the site can be https. Our webhost said they will "install" the certificate on the server for us.

Once they have done that, how do we make it so when someone types www.oursite.com into their browser, it automatically goes to https://www.oursite.com and not http://www.oursite.com?

Also, we have many hardcoded links in the site that point to various other pages on the site but use the full URL, e.g. http://www.oursite.com/somefolder/somepage.aspx

How do we make it so those links end up going to the https version of the page?

user1946932
  • 474
  • 1
  • 16
  • 41

2 Answers2

2

Create a file and rename it ".htaccess" to ur public_html.

it will add auto redirect links to "https://" protocol.

write ur own website adress..

    RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.yourwebsite.com/$1 [R,L]
  • Thanks. I'm not 100% sure I understand you. So the last line does include the {} or should I delete them? – user1946932 Dec 16 '16 at 04:42
  • @user1946932 : Yes, you should turn that part into your website URL. This: `RewriteRule ^(.*)$ https://{yourwebsitelink}/$1 [R,L]` could for example be this: `RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]`. – Visual Vincent Dec 16 '16 at 07:34
  • Is .htaccess available to the OP? May not be if they are on IIS. – vbnet3d Dec 16 '16 at 15:36
  • It is on IIS (ASP.NET 3.5). I tried the .htaccess method and it didn't work. Then I tried the answer at http://stackoverflow.com/questions/47089/best-way-in-asp-net-to-force-https-for-an-entire-site but that didn't work. Any ideas? – user1946932 Dec 18 '16 at 22:21
1

For automatically redirect http to https you can ask your webhost.Normaly they can do. Check this link for others methods

For hardcoded links: Replace 'http' or 'https' with '//', for example instead of http://yoursite.com/script.js use //yoursite.com/script.js .However I recommend to use relative path, if it's possible.

For Web control or server controls you can use Tilda "~" or Control.ResolveUrl. for example :

<asp:HyperLink NavigateUrl="~/views/view.aspx" runat="server" />

<a href="~/views/view.aspx" runat="server" >

<a href="<%= Page.ResolveUrl("~/views/view.aspx") %>"></a>
Shadmehr
  • 278
  • 4
  • 13