Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS

Change url appearance

Go to End

10 Posts   4056 Views


18 September 2009 at 8:35am Community Member, 4 Posts


I just learned about cms/framework silverstripe.
Great cms, except few things. Here they are:

1. No reaction for error 404. For example:

Works! but.. should work just first page, others should cause error 404 How I ca do it?

2. I would like to add .html extension for pages, its very importnant for me.
For exmaple:
And all other pages:
Should cause error 404

Please advice about this. Thank you very much for your support in this matter.


18 September 2009 at 3:37pm Forum Moderator, 921 Posts

URLs with an extension aren't supported, because SS relies on URL rewriting from the web server to operate.

Why are extensions with .html important? I don't really see the need for these anymore. The web has moved on since the static HTML days. :-)


19 September 2009 at 9:52pm (Last edited: 19 September 2009 9:56pm), Community Member, 4 Posts

I am from Russia.

In Russian internet very popular search engine popular than
And search engine yandex very like site with extension .html.
I do not see anything wrong in adding extensions. Html
Good people ask you to help, tell me in what direction to edit the code system, to work extensions .html

P.S. sorry for my bad english.


20 September 2009 at 9:19am Community Member, 528 Posts

There are URL rewrite options. On my site if you add non-existant URL data at the end of the HURl you get a 404.

Check this it may help


20 September 2009 at 11:52pm (Last edited: 21 September 2009 12:06am), Community Member, 901 Posts

Here's a rewrite rule, that will force .html endings for all pages except the core (SilverStripe) URLs:

<Files *.ss>
Order deny,allow
Deny from all
Allow from

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} !(\.gif$)|(\.jpg$)|(\.png$)|(\.css$)|(\.js$)

RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
# match home
RewriteRule ^/?$ sapphire/main.php?url=/&%{QUERY_STRING} [L]
# match predefined silverstripe urls
# the following rule must be written on one line,
# like this: ...processes)(?:/.+)?)$ sapphire/...

RewriteRule ^((?:admin|dev|db|Security|images|api|soap|PageComment|processes)(?:/.+)?)$ sapphire/main.php?url=$1&%{QUERY_STRING} [L]
# everything else must end with .html
RewriteRule ^(.*)\.html$ sapphire/main.php?url=$1&%{QUERY_STRING} [L]

Your "help-and-support" page will then be accessible through
But: This solution doesn't provide automatic output of .html endings when code is being generated. You could simply override the SiteTree Link method in your Page class. Something like this should do:

public function Link($action = null) {
   if($action == 'index') {
      $action = '';
   if($this->URLSegment == 'home' && !$action) return Director::baseURL();
   else return Director::baseURL() . $this->URLSegment . (!$action ? '.html' : "/$action.html");

This will actually create links with .html ending in your templates and works for most cases. It doesn't work when links are being inserted directly in the content area via CMS, also link backtracking will be broken (eg. changing a URL of a page won't automatically update all links to that page). For that to work, you must implement your own link backtracking and rewriting. Have a look at the SiteTree::onBeforeWrite method to get a clue how this could be done...


22 September 2009 at 4:17am Community Member, 4 Posts

Thank you very much!

Jesse B.

21 August 2010 at 2:34am Community Member, 2 Posts

In my case, I work for a company that has spent a great deal of time and money on SEO, and has static pages currently. They would be unwilling to lose their inbound links due to changing urls on specific pages. The only way they will let me move the site to SilverStripe or any CMS is if the urls can be EXACTLY the same as they currently are. Other CMS (drupal for example) allow this, but I would rather use silverstripe.

Some of the solutions provided in this thread offer a uniform solution, i.e. all pages will be reformatted in the same way, however, to complicate things the legacy naming is inconsistent. Some pages end in .html, some in .htm. some uses dashes between words and others use underscores.

I really need to be able to specify an exact url on every page without it being overwritten by any naming convention, in order to satisfy my client's requirement of maintaining the current naming scheme. Has anyone worked out a way to do this? basically I would want to "turn off" all naming convention and have the url be exactly what I type.

Sean, it would be a mistake to think that any convention satisfies all use cases, even if it is a better convention. sometimes we have to work within the confines of legacy sites and client whims.


21 August 2010 at 2:59am Community Member, 528 Posts

The best option though more involved is to set up 301 redirects from the old pages to the new. This is what I did on my sites when transitioning form a static site to SilverStripe. This way you don't loose any link love

The URL of Silverstripe is already SEO Optimized since the page title is the link by default (plus you can customize under the Meta tab). And in 2.4 you have hierarchical URLs. The URL Path vs Document seems to be a fairly debatable issue in terms of SEO, but what it comes down to is as long your URL contains the keywords it doesn't matter if its a path or a document.

I tend to Modify the Title and Navigation Link as well as the Meta path on many of my pages. Especially on press release page since the full article title is sometimes too long.

Go to Top