Custom Home Page
A custom homepage (which uses a URL other than index) can be created by redirecting the default /index path using a Vanity URL (for each respective host). To specify a custom homepage URL for a site, add a Vanity URL with the following dotCMS reserved URL to ONE Vanity URL on the site:
Note: For information on how to create a default homepage for your site, please see the Creating a Homepage documentation.
Custom Error Pages
Custom error pages can be created for each host by redirecting their default path via Vanity URL (for each respective host). These are the steps to take.
1. Create your custom error page as a regular page in dotCMS: for instance /error-pages/404.dot
2. Create a virtual link with the following properties. Use the exact title and URL or the Vanity URL won't work.
- Title: “cms404Page”
- Applies to: define whether the Custom Error page will be used by “All Hosts” or a specific host.
- URL: “/cms404Page”
- Enter URL to Redirect to: your page location for example “/error-pages/404.dot”
This applies to the following error pages:
Global and Local Custom Error Pages
When creating a Vanity URL, there is a drop down select field option for setting the Host that the Vanity URL “Applies to“:
“All Hosts” option-allows a relative or discrete path to be set for “ALL HOSTS” managed by dotCMS when handling the error type.
Localpath: /folderpath/my404errorpage.dot (each host has its own custom error page using the exact same location and pagename)
Global or External Path: http
://myglobalsite/myfolderpath/my404errorpage.dot (This requires the creation of one host to serve as a “global” error page repository)
In this case, the following parameters will be passed in the url:
- ep_originatingHost: domain on which the error occurred
- ep_errorCode: the type of error that ocurred
- ep_error_uri: the url that caused the error
This way a “smart” error page can then detect these parameters set in the url and react with a custom response based on those parameters. In other words, one smart error page can be the global error page for many sites but still display custom error messaging for each domain/host from which the error was generated. This is a feature developed to multi-tennent sites to have “catch-all” custom error pages that still deliver error messaging/styling that appears specific to each host.
Specific Host- allows a relative or discrete path to be set for a each host individually when handling the error type. This option allows Custom error page pathing and error pages to be customized to each host individually
Localpath: /folderpath/my404errorpage.dot OR
Global or External Path: http://myglobalsite/myfolderpath/my404errorpage.dot (This requires the creation of one host to serve as a “global” error page repository)
Redirecting Error pages to a Global or External Host
The host that originated the error, the error code itself, and the bad path attempted (errorURI), can be retrieved by adding the following lines to the velocity on custom error pages:
#set($hostWithError = $request.getParameter('ep_originatingHost')) #set($errorCode = $request.getParameter('ep_errorCode')) #set($errorUri = $request.getParameter('ep_error_uri'))
Webmasters can manage custom error pages on all sites from the same “default host” or allow each host to maintain its own custom error pages using the options provided above. These custom error pages can be relatively pathed or use discrete error page URL paths to other hosts or even to external pages.