custom_error_pages_for_your_site
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
custom_error_pages_for_your_site [2022/02/13 22:35] – jquah | custom_error_pages_for_your_site [2024/09/02 23:19] (current) – ' hc9 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Adding custom error pages to your SDF website ====== | ====== Adding custom error pages to your SDF website ====== | ||
- | The HTTP protocol, which is used to retrieve documents (usually web pages) from the internet for display in a web browser, provides a number of [[https:// | + | The HTTP protocol, which is used to retrieve documents (usually web pages) from the internet for display in a web browser, provides a number of [[wp>List_of_HTTP_status_codes| standard error codes]] to indicate conditions or status relative to the process. The most widely known of these is the notorious code 404 - “File not found.” This error may occur for a number of reasons, but most commonly it indicates a broken link. Perhaps there is a typographical error in your html, or maybe the document was moved to a new location without the needed changes made to the referring link. What happens at this point is that the web browser asking for the missing document receives a special error message web page instead. This page is usually provided by the server, but may in some instances be generated by the browser. The error page may be rather generic, or it may be customized for the originating site. |
===== Why create a custom error page? ===== | ===== Why create a custom error page? ===== | ||
Line 23: | Line 23: | ||
Creating the custom error page itself is just like creating any other web page. Thus, it is somewhat beyond the scope of this article, as really you can do what you like. But if you are short of ideas, check out [[http:// | Creating the custom error page itself is just like creating any other web page. Thus, it is somewhat beyond the scope of this article, as really you can do what you like. But if you are short of ideas, check out [[http:// | ||
- | The key to making your custom error page work is in correctly informing the Apache web server that you have created a custom document and precisely indicating where that document is located. This is accomplished through an entry in the ".htaccess" | + | The key to making your custom error page work is in correctly informing the Apache web server that you have created a custom document and precisely indicating where that document is located. This is accomplished through an entry in the “.htaccess” file. |
- | For the purposes of this discussion, we'll assume you already have your website set up. The root folder of your html directory structure is where you need to create | + | For the purposes of this discussion, we'll assume you already have your website set up. The root folder of your html directory structure is where you need to create |
cd ~/html | cd ~/html | ||
- | If you are using SDF's vhost services, you need to change to the directory for the website you are updating | + | If you are using SDF's vhost services, you need to change to the directory for the website you are updating |
pico .htaccess | pico .htaccess | ||
Line 35: | Line 35: | ||
Of course, while pico is the editor I like to use, you have your choice of several others and should feel free to use the one you like. You can also create or edit the file on your own system and upload it to SDF just as you would any other web document. | Of course, while pico is the editor I like to use, you have your choice of several others and should feel free to use the one you like. You can also create or edit the file on your own system and upload it to SDF just as you would any other web document. | ||
- | With the Apache web server, as used on SDF, ".htaccess" | + | With the Apache web server, as used on SDF, “.htaccess” provides |
In our scenario, you are probably creating a new file, so you'll be starting with a blank slate. You will need to create one line for each error page that you define. To indicate to the server that you want to use your own code 404 message, you'll need to add a line that is similar to this one: | In our scenario, you are probably creating a new file, so you'll be starting with a blank slate. You will need to create one line for each error page that you define. To indicate to the server that you want to use your own code 404 message, you'll need to add a line that is similar to this one: | ||
Line 43: | Line 43: | ||
</ | </ | ||
- | "ErrorDocument" | + | “ErrorDocument” indicates that you are defining your own, “404” is the error code you are taking responsibility for, and ''/ |
===== Changes needed if you use Apache' | ===== Changes needed if you use Apache' | ||
Line 56: | Line 56: | ||
Here are two possible ways to let your visitors use either style of URL, and still get your customized error page if they make a typo. They both involve duplication of the hosted content and (possibly manual) sync jobs. (To avoid these complications you might choose to: (a) disable the tilde-style URL --- '' | Here are two possible ways to let your visitors use either style of URL, and still get your customized error page if they make a typo. They both involve duplication of the hosted content and (possibly manual) sync jobs. (To avoid these complications you might choose to: (a) disable the tilde-style URL --- '' | ||
- | * **Option 1:** Delete the public_html symlink created by '' | + | * **Option 1:** Delete the public_html symlink created by '' |
* **Option 2:** Upgrade your membership to MetaARPA and toggle vanity domain hosting to the MetaArray. The tilde-style URL will still resolve to the cluster, where '' | * **Option 2:** Upgrade your membership to MetaARPA and toggle vanity domain hosting to the MetaArray. The tilde-style URL will still resolve to the cluster, where '' | ||
===== Other changes you might need ===== | ===== Other changes you might need ===== | ||
- | If you place the document in a subdirectory off your html root, you need to indicate that path in ".htaccess". If you are creating custom pages for additional codes, simply add the appropriate lines in ".htaccess". | + | If you place the document in a subdirectory off your html root, you need to indicate that path in “.htaccess”. If you are creating custom pages for additional codes, simply add the appropriate lines in “.htaccess”. |
After making your changes, it may be a good idea to reset the permissions on your website by entering the command: | After making your changes, it may be a good idea to reset the permissions on your website by entering the command: | ||
Line 72: | Line 72: | ||
[[http:// | [[http:// | ||
+ |
custom_error_pages_for_your_site.1644791713.txt.gz · Last modified: 2022/02/13 22:35 by jquah