How can I setting up redirect from www. to https.?

Mr Who asked on May 17, 2021 08:13

Hello everyone,

I tried to add redirect rule in rewrite section (web.config) but it is not work for me (idk why). I saw this https://stackoverflow.com/questions/52170128/www-and-http-in-kentico-iis-redirect but I didn't quite understand what to do and where to do it. I will be very grateful for any help

Thank you

Correct Answer

Juraj Ondrus answered on May 18, 2021 08:01

If you are using portal engine, you can use the mentioned setting in Kentico. IF you are using MVC, then you can configure your routing to do the redirection or use the IIS URL Rewriting rules - there are many discussions threads on the Internet with samples on how that rule should look like.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Juraj Ondrus answered on May 17, 2021 09:17

That thread is talking about IIS URL Rewriting rules. You can add rules through the IIS Management console or if you know the syntax, you can add the rules directly into the web.config file of your application (this is what the IIS console does - it adds entries to the config file too)

0 votesVote for this answer Mark as a Correct answer

Mr Who answered on May 17, 2021 14:33

Hello Juraj,

Thank you for your answer. but immediately after I add the rules to web.config, my site stops working (500 error) and the kentico admin panel. In the error, it points to the rewrite line.

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on May 17, 2021 14:48

Then there is either a mistake in it, or you don't have the module for IIS installed.

You can download it here: https://www.iis.net/downloads/microsoft/url-rewrite

1 votesVote for this answer Mark as a Correct answer

Mr Who answered on May 18, 2021 07:25

Hello David,

I've installed url rewrite module but it didn't help for me. I've restarted my computer but I still recive the same error 500.19. Any ideas? :)

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on May 18, 2021 07:32

There is probably a mistake or syntax error. I would use Google to find some examples of how such a rewrite rule should look like. Or, although it is not clear what you want to achieve, but if you are using portal engine, you can use this setting in Kentico: Settings -> URLs and SEO -> Process domain prefix So, with this setting you can e.g. enforce always to have www or non-www URL or leave it as it is. But in general, handling this on the IIS level using the rules is better for performance.

0 votesVote for this answer Mark as a Correct answer

Mr Who answered on May 18, 2021 07:52

Hello Juraj,

At the moment, use the moment to enter the name of the site both with and without www. In this regard, from the point of view of seo, there are two different sites (two domain names). We need the user to always be redirected to the correct url without www

0 votesVote for this answer Mark as a Correct answer

Mr Who answered on May 18, 2021 08:18

Ok, thank you so much guys :)

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.