|
| support index :: htaccess |
|
.htaccess Overview We do not offer support for .htaccess modifications. The following examples will work on our systems, and we offer them as a courtesy to our customers. You can create .htaccess by using Password Protect from your cPanel. The cPanel will only allow you to password protect. Additional Modifications are to be made by you manually. You cannot use htaccess files with a Windows based Hosting plan.
The .htaccess file is an ASCII text document that can be placed in any directory on your site. It can be used to control access to files and directories, and customize some server operation in your site. An .htaccess file can be created in any word processor but must be saved as text only. You must use FTP software in ASCII mode to upload your .htaccess file or you must edit within telnet. For the examples provided here, place the .htaccess file in your root directory. You will need the following basic skills:
The ".htaccess" file is just that. A file called .htaccess located in one or many of the directories in your virtual server. Traditionally this file has controlled access to the pages in a directory (thus the access part of the file name). With the newer versions of Apache, some of the server configuration parameters are controllable from the file. When your virtual server goes to hand out a file, it starts checking in the top directory for a .htaccess file, and then checks each subdirectory down to and including the directory that your file is in. Thus you can set the defaults for a virtual server by placing a .htaccess file in the top directory of that virtual server, or for multiple virtual servers at once by placing the file in your home directory (e.g. one directory above the top directories of all your virtual servers). Below are some examples of its uses. This is a nice simple way to push a browser over to a different page if you've re-organized your web-site If you moved a page in somedir from old.htm to new.htm then the appropriate line to add to your .htaccess file would be: Redirect /somedir/old.htm http://your.domain/somedir/new.htm Since you get to specify the full URL to the new page, you can bounce the browser to another server if you want. This also works for directories to. We've all seen this before: File Not found - The requested URL /someone/mistyped/a/link.html was not found on this server. These pages are examples of Error Documents. Most types of errors that the web server can run into have error numbers. For example "Not Found" is error 404. ( List of Errors below.) The specification of an error document is easy. You add "ErrorDocument", the three digits of the error number and the either the error string or the page to go to. The following examples show the three forms: ErrorDocument 401 "<body bgcolor=#ffffff><h1>You
have to <b>BUY</b> a ErrorDocument 403 /somedir/forbidden.html ErrorDocument 404 http://yourdomain.com/somedir/notfound.html Error in Client:- Number Description Error in Server:- 500 Internal Error Changing Mime-types is easy. Just create a .htaccess file that looks like this: AddType new-mime-type xxx Note the period is not used in the extension the above extension would be for .xxx files The following is an example use of the .htaccess file. Let's assume
then the path and filename of the .html file you would like to be that
it resides at Add the following to the .htaccess file: <Limit GET> This is an example of a .htaccess file that will block access to your site to anyone who is coming from any IP address beginning with 128.23.45 and from the specific IP address 207.158.255.213. By specifying only part of an IP address, and ending the partial IP address with a period, all sub-addresses coming from the specified IP address block will be blocked. You must use the IP addresses to block access, use of domain names is not supported. This should help you set up protection on a directory via the Basic HTTP Authentication method. This method also uses the standard plaintext password file. So let's suppose you want to restrict files in a directory called turkey to username pumpkin and password pie. Here's what to do: Create a file called .htaccess in directory turkey that looks like this: AuthUserFile /home/someuser/www/.htpasswd <Limit GET> Note that the password file will be in another directory AuthUserFile must be the full Unix pathname of the password file. Also note that in this case there is no group file, so we specify AuthName can be anything you want. The AuthName field gives the Realm name for which the protection is provided. This name is usually given when a browser prompts for a password, and is also usually used by a browser in correlation with the URL to save the password information you enter so that it can authenticate automatically on the next challenge. AuthType should be set to Basic, since we are using Basic HTTP Authentication. Other possibilities for are PEM, PGP, KerberosV4, KerberosV5, or Digest. These would specific to a custom install In this example, only the method GET is restricted using the LIMIT directive. To limit other methods (particularly in CGI directories), you can specify them separated by spaces in the LIMIT directive. For example: <LIMIT GET POST PUT> If you only use GET protection for a CGI script, you may be finding
that the REMOTE_USER environment variable is not getting set when using Create the password file /home/someuser/www/.htpasswd The easiest way to do this is to use the htpasswd program distributed with HTTPd. Do this: htpasswd -c /home/someuser/www/.htpasswd pumpkin Type the password -- pie -- twice as instructed. Check the resulting file to get a warm feeling of self-satisfaction; it should look like this: pumpkin:y1ia3tjWkhCK2 That's all. Now try to access a file in directory turkey -- your browser should demand a username and password, and not give you access to the file if you don't enter pumpkin and pie. If you are using a browser that doesn't handle authentication, you will not be able to access the document at all. Advanced Accecss Control If you want to give access to a directory to more than one username/password pair, follow the same steps as for a single username/password with the following additions: Add additional users to the directory's .htpasswd file. Use the htpasswd command without the -c flag to add additional users; e.g.: htpasswd /home/someuser/www/.htpasswd peanuts Create a group file. Call it /home/someuser/www/.htgroup and have it look something like
this: ... where pumpkin, peanuts, almonds, and walnuts are the usernames. Then modify the .htaccess file in the directory to look like this: AuthUserFile /home/someuser/www/.htpasswd <Limit GET> Note that AuthGroupFile now points to your group file and that group my-users (rather than individual user pumpkin) is now required for access. That's it. Now any user in group my-users can use his/her individual username and password to gain access to directory turkey. Following are several examples of the range of access authorization capabilities available. Protection by network domain. This document is only accessible to clients running on machines inside render-vue.com. AuthUserFile /dev/null <Limit GET> Protection by network domain -- exclusion. This document is accessible to clients running on machines anywhere but inside domain verio.net AuthUserFile /dev/null <Limit GET> Add the following to the .htaccess file: DirectoryIndex filename.html Then a request for http://domain-name.net/ would return To automatically run a cgi script, add the following to the .htaccess file: DirectoryIndex /cgi-bin/index.pl This would cause the CGI script /cgi-bin/index.pl to be executed. If you place your .htaccess file containing the DirectoryIndex specification in the root directory of your site, it will apply for all sub-directories at your site. FRONTPAGE
WARNING: FrontPage sites have a .htaccess file in the root directory that is created when the FrontPage extensions are installed. FrontPage users should proceed with caution and make a backup copy of their .htaccess file before making any changes. Incorrect changes to your .htaccess file can result in your site being unreachable. What is .htaccess? Can I use frontpage and .htacces
at the same time? Is there an easier way than
manualy making .htaccess? |
|
copyright render-vue 1999 - © all rights reserved |