Lissa Explains it All -- HTML Help for Kids


| Section 1 | Section 2 | Section 3 | Section 4 |
| Section 5 | Section 6 | Section 7 | Section 8 |
| Section 9 |


How do I make server side includes (SSI)?
How do I make php includes?
How do I make custom 404 error documents?
How do I prevent direct linking of my images?
How do I block ip addresses?



How do I make server side includes (SSI)?    The most practical use of server side includes is to edit a large amount of pages just by editing one file. If you have a large site, using server side includes can make it a breeze to update your pages. As you may have noticed, my pages all have the .shtml extension instead of the regular .html extension. This is because I use SSI on my site to make it easier to update. I use it for the left navigation menu, my header, and my footer. My navigation menu is actually a text file that I upload to my server. A small code included in my .shtml document calls the text file when needed to make it appear on my site. I can update every page that has a menu just by updating that one .txt file and uploading it to my server. Since I have 50 + pages, it makes it so much easier to update. Keep in mind that not all servers allow the use of SSI, and you will probably have to rename all of your regular .html documents to .shtml (some servers allow you to continue to use the .html extension, but not many of them do).

First, rename your regular .html documents to .shtml.

Next, make a text file (you can use Notepad). You can name the text file with the extension .txt, .html, or .shtml, it depends on what you want. The text file can include HTML, javascript, music, whatever you want to show up on a large number of pages. After you've made the text file, save it with the .txt file extension, name it anything you want.

Insert this code in your .shtml document, changing the info in bold to reflect your filename:

<!--#include file="yourfilename.txt" -->

Now, when someone accesses your site, the text file will be inserted into your document and show up as regular html.

It's really not very hard, and it's an awesome tool if you have a large site!

up


How do I make php includes?    Php includes are essentially the same thing as SSI includes. Your host has to support php and your html files need to be named with the extension .php instead of .html or .shtml.

First, rename your regular .html documents to .php.

Next, make a text file with the extension .php and add whatever you want in your include.

Insert this code in your regular .php document, changing the info in bold to reflect your filename:

<? include("yourfilename.php") ?>

Now, when someone accesses your site, the text file will be inserted into your document and show up as regular html.

up


How do I make custom 404 error documents?    A 404 error page is a page that shows up if someone tries to access a page that doesn't exist on your domain. This is very easy to do, however, you do have to have your own domain to do this in most cases. Upload a text file with FTP to your main directory with the following line:

ErrorDocument 404 http://www.yourdomain.com/error.html

Change the information in bold text to your own information (your domain and the url to your error page). After you've done that, save the file as .htaccess Make sure to include the dot in front. Next you need to make your error page. This is a regular HTML document that lets people know they've reached that page in error.

Upload the error page, and now when you type in an incorrect url to your domain, your custom error page will appear. You can add whatever you want to your error page, a redirect to your main site is always a good thing to include.

An .htaccess file is a plain text file that contains server directives. You add these directives line by line, one on each line. They can be added in a main directory or a subdirectory, but if you add it into the subdirectory it will cancel out any .htaccess file you have in the main directory. Some things you can do with .htaccess are error documents, password protection, and image protection.

up


How do I prevent direct linking of my images?    I have had a lot of trouble with people direct linking or hot linking to my images. The biggest problem I have with it is that it costs me so much money in bandwidth charges when people direct link. Bandwidth theft is also a big problem for those with free graphics sites. As long as you own your own domain, or your free host allows you to upload .htaccess files, preventing direct linking is a very simple thing to do. You upload a txt file which you name .htaccess . On the text file, add these lines:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]

Change nothing in the above lines except for your domain name. Upload the text file, named .htaccess, to your main directory. It's that easy. As long as your host supports mod rewrite, no one will be able to direct link to your .gif or .jpg images!!!

If you're using more than one .htaccess file, you would just combine them. My .htaccess file looks like this:

htaccess


Feeling evil? You could always replace the direct linked image with another image of your choice such as "direct linking not allowed," "direct linkers are evil," or an advertisement for your site (free advertising hehe). Use this code instead of the above code:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.yourdomain.com/evil.gif [R,L]

Replace your domain name and the file name of the gif you want to show up when someone direct links. Have fun!!!

up


How do I block ip addresses?You can block ip addresses from viewing your site by adding a small .htaccess file to your root directory. Just copy and paste the following into a text document, make sure you name the file extension .htaccess :

<Limit GET>
order deny,allow
deny from 000.00.000.000
</Limit>

Upload it to your root directory, or to whichever directory you need to block the ip address from. If you upload it to your root directory, it blocks the ip address from your entire site. If you upload it into a subdirectory, it blocks the ip only from that subdirectory.

up





| About Lissa | Privacy Statement | Contact | Link Us |

Copyright 1997-2016 Lissa, All rights reserved
This Web site is registered with the Library of Congress Copyright Office.


lissaexplains.com


Lissa Explains it All -- HTML Help for KidsHTML Help, css, frames, tables, div layersCustom CursorsHTML Help ForumFree E-mail Service for Kids (and adults who love bright colors ;)Lissa Explains it All -- Free PostcardsLissa Explains it All -- MerchandiseLissa Explains it All -- Guestbook
HTML BasicsHTML TutorialCSS TutorialFrames TutorialTables TutorialColor TutorialFree JavascriptsFun Free Stuff for your siteMySpace TutorialHTML Tutorial
spacer