HT: Difference between revisions
Jump to navigation
Jump to search
revision 3
(revision 2) |
(revision 3) |
||
Line 1: | Line 1: | ||
This article will help you understand and build your knowledge of the .htaccess file you see when you run an Apache Web Server like ours. | This article will help you understand and build your knowledge of the .htaccess file you see when you run an Apache Web Server like ours. | ||
'''''Note''': Article is still under editing'' | |||
==What is a .htaccess file?== | ==What is a .htaccess file?== | ||
Line 10: | Line 10: | ||
==Usage and Commands== | ==Usage and Commands== | ||
Here are some examples as to how they can be used. | |||
===Change the Default Directory Index File=== | |||
It can be used to chnage the default index file which is normally index.html, index.ext... to anything like foo.ext or whatever name/extension you prefer. To do this, use: | |||
<pre>DirectoryIndex foo.ext home.html home.php foo.php</pre> | <pre>DirectoryIndex foo.ext home.html home.php foo.php</pre> | ||
===Customizing Error Handling/Error Pages=== | |||
If you have ever wondered how people chnage their 404, 500... error pages to something like lost.ext, then you will like this code in your .htaccess file: | |||
<pre> | <pre> | ||
<nowiki> | <nowiki> | ||
Line 21: | Line 26: | ||
Where [Error Number] is replaced with the error number, and [Error Document] is replaced with the path fo the error document which can be internal or external as in: | Where [Error Number] is replaced with the error number, and [Error Document] is replaced with the path fo the error document which can be internal or external as in: | ||
<pre>http://www.anothersite.com/foo.ext or /foo.ext</pre> | <pre>http://www.anothersite.com/foo.ext or /foo.ext</pre> | ||
===Server Generated URL Redirects=== | |||
You moved or renamed a directory and you know people still have the old directory bookmarked so you want them to be redirected to the new directory, then you can use this code: | |||
<pre>Redirect [Trigger] [New Destination] | <pre>Redirect [Trigger] [New Destination] | ||
Redirect /old http://www.url.com/new | Redirect /old http://www.url.com/new | ||
Redirect /old /new</pre> | Redirect /old /new</pre> | ||
===Limiting Access by Hostname/IP Address=== | |||
Use this section of this article if you are intrested in blocking access to a file/folder on your server: | |||
<pre> | <pre> | ||
<Files admin.cgi> | <Files admin.cgi> | ||
Line 61: | Line 70: | ||
</files> | </files> | ||
</pre> | </pre> | ||
===Limiting Access by User=== | |||
This part lets you use a .htaccess/.htpasswd user login system that uses cookies. It is not fully safe because the session does not expire until all open broswers are closed so try not to use it much on your site section that needs foul proof security. Here is the code: | |||
<pre> | <pre> | ||
AuthType Basic | AuthType Basic |