|
| Home | |||||||
PHP Custom 404 Script Installation Quick Guide Transcript
Welcome to the PHP custom 404 script installation quick guide. The implementation of the custom 404 solution requires a higher level of technical expertise than the dynamic solution but has benefits that the dynamically driven links directory does not. The primary advantage to the custom 404 solution is the URL which is used. The custom 404 solution does not use any parameters associated with dynamically created web pages and is considered by the search engines to be standard HTML pages. The standard HTML output will make your visitors and the search engines believe that the page is a static HTML page when in reality it is dynamically created. In this tutorial we are using RHEL4 and depending on what OS version you are using the following steps may differ. This guide will demonstrate how to quickly install and configure your custom 404 links directory. Click next to begin the tutorial.
The first task at hand to configure your custom 404 links solution is to create a folder at the root of your website. You can name this folder whatever you like, but in this example we are going to stay with the default and name it “directory”. Once you have created your new folder you will need to create a PHP file where you will place your script code. For purposes of this example we are going to name our file “resources.php” and place the file into our new folder (“directory”). You can name the file anything you want as it will have no effect on your links directory, but you will need to know the name of the file so that you can point any 404 Errors to the file.
Now that we have created our “directory” folder and “resources.php” file, we need to configure the custom 404 error handler to point to the specific directory and file we created in the previous step. Open the HTTP settings window. Click on the Virtual Hosts tab and highlight your website, then click the edit button. Once the Virtual Host Properties are displayed, click the Page Options tab, and scroll down to the Not Found error code and click the edit button. The “Error Code: 404 – Not Found” window is displayed; this is where we point to our “resources.php” file to handle our 404 Errors. For Behavior select “URL” from the drop-down box, and for the Location lets’ put in our path to the “resources.php” file /directory/resources.php. To save your settings click the OK button 3 times to save and close out the application.
Now that we have assigned our custom 404 error handlers, we can now logon to MyLinkHelper.com and generate our Custom 404 script. From your main account page select “Get My Link Code” then Select “PHP – Custom 404” from the drop-down menu and click “Get Code”.
Once the PHP – Custom 404 code is selected and submitted, the dynamic code will be displayed for you to copy & paste. Select all of the contents of the text area box and copy the link script.
Lets’ head back to our “resources.php” file within the “directory” folder located at the root of your website. Open the “resources.php” file and paste the Custom 404 script code. Save and close the file.
If you have your website hosted with a web hosting company you might be able to simply create a folder and create or modify the folder’s “[dot]htaccess” file. If you are running PHP Script on an Apache Server and want to use a dynamic PHP page for use as a custom error page you must first create or update the .htaccess file within the desired directory. A .htaccess file is a system file that allows you to override default Apache server instructions. A .htaccess file in one directory affects all the subdirectories that do not have an .htaccess file of their own. The name must be all lowercase i.e. ".htaccess" To configure a custom error page, create (or modify) the .htaccess file in the directory by adding an ErrorDocument. The format is: ErrorDocument [ERRORCODE] [URL] It is best to use the relative path for the URL not a full URL. In our tutorial, our .php file is named “resources.php” and it is in a folder named "directory", the line to add to .htaccess file is: ErrorDocument 404 /directory/resources.php Also, when creating a new .htaccess file, the resulting name may be - htaccess.txt if you create it on a windows system. If so, be sure to remove the extension and rename the file to “.htaccess” once you move it to your server.
Now that the 404 error handler has been configured, and your script has been copied into your “resources.php” file, we can now test the functionality of our links directory. Open a new browser and navigate to your new links directory using the default entry page definition of “main.html”. The entry page to your links directory will always be “main.html” and cannot be changed. As an example using the settings we used for this guide your URL would be similar to http://www.yourwebsite.com/directory/main.html. As you can see in this slide, the links page is displayed properly, and we have successfully configured our Custom 404 link solution. If however, you do not see the directory display and the page is blank, view the source of the page for more information. If you try to access your directory and are immediately redirected to your home page then you will need to modify the “DirFolder” variable within your link script file to reflect the name of the folder you created.
Thank you for watching our PHP custom 404 script installation quick guide. From all of us at the My Link Helper development team, we hope you found this guide useful. If you have further questions, please feel free to contact us at www.mylinkhelper.com/contact.asp. | |||||||
| |||||||