301 redirect from /page.html to /page

Tim G. asked on September 6, 2018 15:28

I'm in the process of porting a static site into Kentico and want to set up redirects from the old /page.html URLS to the new clean friendly URL '/page'.

In settings > URLs and SEO I've set the following:

Friendly URL extensions: '' (blank) Redirect page aliases to main URL: checked Redirect pages to main extension: unchecked

I've then set up a Alias with the following properties: URL Path: '/page' URL Extension: '.html'

However when visting http://mysite/page.html I get a 404.

What am I missing? Any help much appreciated.

Recent Answers


Arun Kumar answered on September 6, 2018 16:35 (last edited on September 6, 2018 16:37)

For global solution you can follow this link. Within Kentico you need to enable extensions for .html under Settings -> URL & SEO -> Friendly URL Extensions if not already to add them as Alias. Check this link to do this within Kentico.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 6, 2018 17:41

Assuming you have the proper web.config (<modules runAllManagedModulesForAllRequests="true">) it sounds like you're only missing adding the ".html" extension here:

Settings>URL & SEO>Friendly URL Extensions

0 votesVote for this answer Mark as a Correct answer

Tim G. answered on September 6, 2018 17:46

Brenden - adding '.html' to Settings>URL & SEO>Friendly URL Extensions does the opposite - it forces the friendly URL to redirect from:

http://mysite/page

to

http://mysite/page.html

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 6, 2018 18:00

Sorry about that, you need to include a blank at the beginning as well so your value should be

;.html;

The blank at the beginning will cover the extensionless URL setup.

0 votesVote for this answer Mark as a Correct answer

Tim G. answered on September 6, 2018 18:05

I sussed that and added this:

Friendly URL Extensions ";.html;.aspx"

This now works as expected with a .aspx extension added but not with .html

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 6, 2018 18:19

If you want extensionless URLs you need to make sure you have

<modules runAllManagedModulesForAllRequests="true">

under the

<system.webServer>

node.

0 votesVote for this answer Mark as a Correct answer

Tim G. answered on September 6, 2018 18:24 (last edited on September 6, 2018 18:26)

I'd already added this and extensionless URLs are already working for .aspx

http://mysite.com/page.aspx

redirects as expected to:

http://mysite.com/page

But I get a 404 on the following:

http://mysite.com/page.html

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 6, 2018 18:39

In your alias on the page, do not include the period.
Your extension should read html not .html

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on July 22, 2019 09:22

It looks like the runAllManagedModulesForAllRequests attribute was not added into the correct place. It has to be added here.

0 votesVote for this answer Mark as a Correct answer

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