Sitefinity 4.2 and using .html page extension

Posted by Community Admin on 03-Aug-2018 01:15

Sitefinity 4.2 and using .html page extension

All Replies

Posted by Community Admin on 09-Sep-2011 00:00

Hello,

I have a page (i.e. /about-us/careers) that I need to come up when I have a .html page extension (i.e. /about-us/careers.html) but all I am getting is a 404. For the page I have the "~/about-us/careers.html" set as an entry under "Allow multiple URLs..." in Title & Properties. I also tried adding the extension in IIS so .html is handled by the .NET 4 aspnet_isapi.dll. It doesn't work with the handler set or not set.  Am I missing something?

Posted by Community Admin on 09-Sep-2011 00:00

Hmmm, what's the use case? Is it an upgrade of an old site and they don't want to lose old links?

IMO /about-us/careers seems way better than /about-us/careers.html

Posted by Community Admin on 12-Sep-2011 00:00

It's a migration of an old site and I, as well, prefer the non-html link but I need the .html link to work in order to support some script that i'm told cannot change. It should be simple to add but it just doesn't work. Before upgrading to Sitefinity 4.2 all I had to do to get the .html extension working was to change the "URL" for the page and everything worked fine. Now, after the upgrade, this does not work and I just get the 404. Any thoughts would be great.

Posted by Community Admin on 12-Sep-2011 00:00

Have you tried setting an "alternate URL" in the page properties?

Would that work?...then no more dead links and the Goog will get updated?

Posted by Community Admin on 13-Sep-2011 00:00

That's the problem, I've added alternate URLs into this list but all I get is 404 errors when I go to those links.

Posted by Community Admin on 29-Sep-2011 00:00

I am having exactly the same issue. The alternate .html urls do not work for me either.
And we have exactly the same situation with needing pages to have a .html extension.
I would prefer not to have to resort to a url rewriting solution...
Anyone know if this is a bug or a feature?

Josh

Posted by Community Admin on 29-Sep-2011 00:00

It looks like sitefinity can take of this at the IIS level by a simple change in the web.config

www.sitefinity.com/.../using-url-rewrite-for-seo.aspx

We do need SEO-friendly-everything so I may pursue this avenue.

In the system.webServer tag after the handlers section in the web.config,
I would just need to do something like:

<rewrite>
            <rules>
                <clear />
                <rule name="LowerCaseRule1" stopProcessing="true">
                    <match url="^(Sitefinity/)" ignoreCase="true" negate="true" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="URL" pattern="[A-Z]" ignoreCase="false" />
                        <add input="URL" pattern="\.axd" negate="true" />
                        <add input="URL" pattern="\.xamlx" negate="true" />
                        <add input="URL" pattern="\.ashx" negate="true" />
                        <add input="URL" pattern="\.asmx" negate="true" />
                        <add input="URL" pattern="\.xap" negate="true" />
                    </conditions>
                    <action type="Redirect" url="ToLower:URL" redirectType="Permanent" />
                </rule>
                <rule name="RemoveTrailingHtmlRule1" stopProcessing="true">
                    <match url="(.*)\.html$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="REQUEST_FILENAME" matchType="IsDirectory" negate="true" />
                        <add input="REQUEST_FILENAME" matchType="IsFile" negate="true" />
                    </conditions>
                    <action type="Redirect" url="R:1" />
                </rule>
            </rules>
        </rewrite>

This is a very small modification of the sample from that link. (RemoveTrailingSlash -> RemoveTrailingHtml)

UPDATE:
Since I edited this post, I have fixed a regex bug and now the code above works perfectly.
I tested this on two machines with Windows 7 64 bit and IIS 7.5.
Please be sure to have 'Url Rewrite 2.0' installed on IIS for this to work properly.
Without this installed, your site will have a web.config error as the rewrite tag will not be supported.

Also noteworthy, there really are two rules here, the first additionally lowercases all requests.
The lowercase rule of course is optional.

Regards,
Josh

Posted by Community Admin on 30-Sep-2011 00:00

Hello Josh,

 Taking care of this at IIS level is the best option (either with a URL rewriter or the way you suggested). 
The extensions which are not allowed for a page url (and if you type such an extension, a 404 error will always be thrown) can be found at Administration >> Advanced >> Pages >> NotAllowedPageExtensions. Before 4.2 SP1, the .htm and .html extensions were also in that list and you could delete them, so after deleting them you could freely use them in your page url and the request would be handled. However, we experienced some issues with this behaviour and decided to make them permanently NotAllowed. There is a way for the extensions to be added to the page url through code, but that is highly not recommended, which again means that using IIS to do that is your best choice.

All the best,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 15-Aug-2012 00:00

multiple ULR work in 5.1 so you can use

~/oldpage
~/oldpage.aspx
~/oldpage.html
~/oldpage.susi

Markus

This thread is closed