X-Cart:404 Error Page
X-Cart provides a 404 error page. The 404 error page is a page used to display the 'Page not found' error message when a visitor attempts to access the store site using a URL for which no page exists. Typically, this happens if the URL being used is spelled wrong, or if the page being requested has been removed.
The 404 error page in X-Cart serves to provide a more user-friendly experience for your store's users: unlike the default 404 error message returned by the web server, it looks nice, follows the design of the other pages in your store, explains the problem in plain words and provides navigation links allowing the user to try other pages on your store site:
At any moment, you can view your store's 404 error page by pointing your browser to the location of your store with the addition of /404.php. For example, if your store's URL is http://example.com, you can view its 404 error page by pointing your browser to http://example.com/404.php.
Please note that X-Cart's 404 error page does not work out of the box. To use it in your store, you need to enable it. The procedure is different depending on the web server you are using. Instructions for enabling the 404 page in X-Cart on the most popular web servers are available in the following sections:
X-Cart's 404 error page is easily customizable. To find out how you can change the content of your store's 404 error page, see the section #Customizing X-Cart's 404 Error Page.
The 404 error page included with the X-Cart distribution package is intended for the English language. If you wish to enable the users of your store speaking in languages other than English to read the contents of the 404 error page in their own languages, you must create a version of the
provide 404 error pages for languages other than English, you must create them. For instructions, see the section #Creating Versions of the 404 Error Page for Other Languages.
Enabling 404 Error Page on Apache
If you are using Apache web server, to enable use of X-Cart's 404 error page in your store, you must edit the .htaccess file located in your X-Cart installation directory as follows:
- Uncomment the following line:
# ErrorDocument 404 /404.php
by removing the leading "#".
- If your X-Cart is installed in a subdirectory (not in the root of the website), edit the uncommented line above to include the full relative path to the 404.php script.
For example, if your X-Cart is installed in the folder /store, so the store is available at the address http://example.com/store/home.php, the said line in your .htaccess file must read as follows:
ErrorDocument 404 /store/404.php
(Note the absence of "#" at the beginning of the line).
Enabling 404 Error Page on IIS
If you are using IIS web server and wish to use X-Cart's 404 error page in your store, you must configure IIS to use the file <xcart_dir>/404.php for the custom 404 error message.
In order to configure IIS, you must be an administrator of the web server (or a member of the Web Site Operators group) and have access to an IIS admin interface. If you do not have administrator privileges and/or physical access to the computer on which the server is run, you will have to ask your administrator to take these steps on your behalf.
To enable use of X-Cart's 404 error page on IIS, do the following:
- In the Internet Information Services snap-in, select your website, right-click, and choose 'Properties'.
- Select the 'Custom Errors' tab.
- Select the HTTP error that you would like to change, in this case 404.
- Click the Edit Properties button.
- From the 'Message Type' drop-down box, select File.
- Enter the full path that points to the file <xcart_dir>/404.php, or use Browse... to locate this file.
- Click the OK button.
Customizing 404 Error Page
The content of X-Cart's 404 error page for the English language is defined by the file 404_US.html located in the directory /xcart/skin1/404/. You can easily change the look and feel, as well as the textual content of your store's 404 error page by editing this file. The editing can be done in X-Cart's built-in template editor (see the section Using Template Editor), or in any decent external text editor.
Creating Versions of the 404 Error Page for Other Languages
If your store supports languages other than English, it is recommended you create a version of the 404 error page for each of the languages in your store. This way your store's non-English speaking users will be able to read the contents of the 404 error page in the language they use to view the rest of your store.
To create a version of the 404 error page for a language other than English, do the following:
- Save the file 404_US.html from the directory /xcart/skin1/404 as 404_XX.html, where XX is an ISO 3166-1 alpha-2 code of the country corresponding to the desired language. You can accomplish this using the 'Browse templates' section of your store's Admin area (Administration menu->Edit templates):
- Browse to the directory /xcart/skin1/404.
- Select the radio button next to the filename 404_US.html.
- In the section 'Copy selected file to...', enter the filename for the new language version of the 404 error page. For example, if you wish to create a version of the 404 error page in German, you must use the filename 404_DE.html.
- Click the Copy button.
- Open the file 404_XX.html that has been created in a text editor. For example, you can use X-Cart's built-in template editor (See X-Cart:Using Template Editor).
- Edit the textual content of the 404_XX.html file translating it from English into the desired language.
- Make sure the page for the language version you are creating uses the correct charset. The charset of X-Cart's 404 error page for the English language is specified in the 404_US.html file as iso-8859-1. If the language into which you are translating this page uses a different charset, be sure to correct the encoding and charset values in your 404_XX.html file.
- Save the file.
Now any users browsing your store in the language of 404_XX.html who get a 404 error will be served the content of 404_XX.html.
To make sure the 404 error page works properly for a specific language, do the following:
- On any page within your store, switch the Language selector at the top of the page to the desired language.
- Edit the URL in the address bar of your web browser so it points to any location that you know does not exist in your store.
- Press Enter.
As a result, you should see your store's 404 error page in the selected language.