Switch From http to https

Topics: Business Logic Layer
Aug 10, 2016 at 9:33 PM
Edited Aug 10, 2016 at 9:42 PM
I recently switched my site to https but Utils.AbsoluteWebRoot does not pick up the change. Is there something I am missing to force the change? I also noticed that the sitemap.axd is still showing http in the urls instead of https
Aug 22, 2016 at 8:48 PM
Can anyone help with this question please?
Dec 5, 2016 at 11:00 PM
Still looking for a solution to this issue. Using BlogEngine.net 2.8
Dec 7, 2016 at 4:07 PM
I switched to https. I use Blogengine 3.3 on IIS.
Used letsencrypt to get certs. No problems.
Dec 19, 2016 at 8:48 PM
Use the method LEOF used. Use IIS as the redirector and set up some rules in your web.config. Use your certs and import them into the SSL settings. IIS is very good at redirecting and SSL termination.
Feb 20 at 4:07 PM
Can you share with me what you added to the web.config to do this? I am doing this but it doesn't work:
   <rule name="HTTP Redirect to HTTPS" enabled="true" stopProcessing="true">
      <match url="(.*)" ignoreCase="false" />
      <conditions>
        <add input="{HTTPS}" pattern="off" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
    </rule>
Feb 20 at 10:41 PM
This works for me
          <rule name="Redirect to HTTPS" stopProcessing="true">
            <match url="(.*)" />
            <conditions>
              <add input="{HTTPS}" pattern="^OFF$" />
              <add input="{HTTP_HOST}" matchType="Pattern" pattern="^localhost$" negate="true" />
            </conditions>
            <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" />
          </rule>
Tue at 9:16 AM
Ok SimonBland but if I want remove date from URL??? I can to make it also????
Tue at 8:49 PM
I don't understand what you are asking. Do you mean that you have links in your blog that used to point to URLs that contained a date. After you removed the date from the URLs the links are broken?

If so, I fixed that problem by adding the following to the RouteConfig.cs file in my main website. I run my blog as an application under my MVC website so this may not work in your case.

Note that this re-directs to the blog home page. I decided to do that because they are URLs of posts that were created in an old version of BE and the URLs changed when I imported them to a new blog site. I did this mainly to get rid of Google crawl errors. You could get them redirected to the correct posts with a bit of extra work (I fixed my broken internal links manually).
            //Blog redirects for legacy names. These are all sent to the blog home page
            routes.MapRoute(
            "BlogEnginePartialDatedPath",
            "blogengine1/{year}/{month}/{path}",
            new
            {
                controller = "Redirect",
                action = "Blog",
            }
            );

            routes.MapRoute(
            "BlogEngineDatedPath",
            "blogengine1/post/{year}/{month}/{day}/{path}",
            new
            {
                controller = "Redirect",
                action = "Blog",
            }
            );

            routes.MapRoute(
            "BlogEnginePath",
            "blogengine1/post/{path}",
            new
            {
                controller = "Redirect",
                action = "Blog",
            }
            );

            routes.MapRoute(
            "BlogEngineNoPath",
            "blogengine1/",
            new
            {
                controller = "Redirect",
                action = "Blog",
            }
            );
Then I have a controller called RedirectController which includes the following:
        public ActionResult Blog()
        {
            return RedirectPermanent("/blog/");
        }
Tue at 11:25 PM
My problelm is this, I remove date from my URL

Before
www.mysite.com/post/2017/03/22/consigli-fantacalcio-23a-giornata

Now
www.mysite.com/post/consigli-fantacalcio-23a-giornata

In Search Google i have duplicate title, before BE don't make redirec 301 permanent..

How can i resolve for you?

Thanks
Fabry
Wed at 3:48 PM
OK. I've explained one way to fix that in my above reply.

If you want to redirect in BE then you can use the rewrite rules in web.config. I tested this on my own instance and it seems to work, however, it may cause routing conflicts so be sure to test it carefully. You may need to change some parts of the rule to make it work.
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="remove year month day" stopProcessing="true">
          <match url="^/([0-9]+)/([0-9]+)/([0-9]+)/([_0-9a-z-]+)$" />
          <action type="Rewrite" url="/post/{R:4}" appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>
</system.webServer>
All the best,
Simon