FAQ: what is .htaccess ??
Forum rules
- guilliam
- Joomla! Enthusiast
- Posts: 159
- Joined: Thu Aug 18, 2005 10:27 am
- Location: Sunny City Cebu, Philippines!
- Contact:
FAQ: what is .htaccess ??
Introduction
In this tutorial you will find out about the .htaccess file and the power it has to improve your website. Although .htaccess is only a file, it can change settings on the servers and allow you to do many different things, the most popular being able to have your own custom 404 error pages. .htaccess isn't difficult to use and is really just made up of a few simple instructions in a text file.
Will My Host Support It?
This is probably the hardest question to give a simple answer to. Many hosts support .htaccess but don't actually publicise it and many other hosts have the capability but do not allow their users to have a .htaccess file. As a general rule, if your server runs Unix or Linux, or any version of the Apache web server it will support .htaccess, although your host may not allow you to use it.
A good sign of whether your host allows .htaccess files is if they support password protection of folders. To do this they will need to offer .htaccess (although in a few cases they will offer password protection but not let you use .htaccess). The best thing to do if you are unsure is to either upload your own .htaccess file and see if it works or e-mail your web host and ask them.
What Can I Do?
You may be wondering what .htaccess can do, or you may have read about some of its uses but don't realise how many things you can actually do with it.
There is a huge range of things .htaccess can do including: password protecting folders, redirecting users automatically, custom error pages, changing your file extensions, banning users with certian IP addresses, only allowing users with certain IP addresses, stopping directory listings and using a different file as the index file.
Creating A .htaccess File
Creating a .htaccess file may cause you a few problems. Writing the file is easy, you just need enter the appropriate code into a text editor (like notepad). You may run into problems with saving the file. Because .htaccess is a strange file name (the file actually has no name but a 8 letter file extension) it may not be accepted on certain systems (e.g. Windows 3.1). With most operating systems, though, all you need to do is to save the file by entering the name as:
".htaccess"
(including the quotes). If this doesn't work, you will need to name it something else (e.g. htaccess.txt) and then upload it to the server. Once you have uploaded the file you can then rename it using an FTP program.
Warning
Before beginning using .htaccess, I should give you one warning. Although using .htaccess on your server is extremely unlikely to cause you any problems (if something is wrong it simply won't work), you should be wary if you are using the Microsoft FrontPage Extensions. The FrontPage extensions use the .htaccess file so you should not really edit it to add your own information. If you do want to (this is not recommended, but possible) you should download the .htaccess file from your server first (if it exists) and then add your code to the beginning.
Custom Error Pages
The first use of the .htaccess file which I will cover is custom error pages. These will allow you to have your own, personal error pages (for example when a file is not found) instead of using your host's error pages or having no page. This will make your site seem much more professional in the unlikely event of an error. It will also allow you to create scripts to notify you if there is an error (for example I use a PHP script on Free Webmaster Help to automatically e-mail me when a page is not found).
You can use custom error pages for any error as long as you know its number (like 404 for page not found) by adding the following to your .htaccess file:
ErrorDocument errornumber /file.html
For example if I had the file notfound.html in the root direct
ory of my site and I wanted to use it for a 404 error I would use:
ErrorDocument 404 /notfound.html
If the file is not in the root directory of your site, you just need to put the path to it:
ErrorDocument 500 /errorpages/500.html
These are some of the most common errors:
401 - Authorization Required
400 - Bad request
403 - Forbidden
500 - Internal Server Error
404 - Wrong page
Then, all you need to do is to create a file to display when the error happens and upload it and the .htaccess file.
PLEASE READ THE WHOLE ARTICLE IN ITS HOME SITE:
http://www.freewebmasterhelp.com/tutorials/htaccess/1
- g
In this tutorial you will find out about the .htaccess file and the power it has to improve your website. Although .htaccess is only a file, it can change settings on the servers and allow you to do many different things, the most popular being able to have your own custom 404 error pages. .htaccess isn't difficult to use and is really just made up of a few simple instructions in a text file.
Will My Host Support It?
This is probably the hardest question to give a simple answer to. Many hosts support .htaccess but don't actually publicise it and many other hosts have the capability but do not allow their users to have a .htaccess file. As a general rule, if your server runs Unix or Linux, or any version of the Apache web server it will support .htaccess, although your host may not allow you to use it.
A good sign of whether your host allows .htaccess files is if they support password protection of folders. To do this they will need to offer .htaccess (although in a few cases they will offer password protection but not let you use .htaccess). The best thing to do if you are unsure is to either upload your own .htaccess file and see if it works or e-mail your web host and ask them.
What Can I Do?
You may be wondering what .htaccess can do, or you may have read about some of its uses but don't realise how many things you can actually do with it.
There is a huge range of things .htaccess can do including: password protecting folders, redirecting users automatically, custom error pages, changing your file extensions, banning users with certian IP addresses, only allowing users with certain IP addresses, stopping directory listings and using a different file as the index file.
Creating A .htaccess File
Creating a .htaccess file may cause you a few problems. Writing the file is easy, you just need enter the appropriate code into a text editor (like notepad). You may run into problems with saving the file. Because .htaccess is a strange file name (the file actually has no name but a 8 letter file extension) it may not be accepted on certain systems (e.g. Windows 3.1). With most operating systems, though, all you need to do is to save the file by entering the name as:
".htaccess"
(including the quotes). If this doesn't work, you will need to name it something else (e.g. htaccess.txt) and then upload it to the server. Once you have uploaded the file you can then rename it using an FTP program.
Warning
Before beginning using .htaccess, I should give you one warning. Although using .htaccess on your server is extremely unlikely to cause you any problems (if something is wrong it simply won't work), you should be wary if you are using the Microsoft FrontPage Extensions. The FrontPage extensions use the .htaccess file so you should not really edit it to add your own information. If you do want to (this is not recommended, but possible) you should download the .htaccess file from your server first (if it exists) and then add your code to the beginning.
Custom Error Pages
The first use of the .htaccess file which I will cover is custom error pages. These will allow you to have your own, personal error pages (for example when a file is not found) instead of using your host's error pages or having no page. This will make your site seem much more professional in the unlikely event of an error. It will also allow you to create scripts to notify you if there is an error (for example I use a PHP script on Free Webmaster Help to automatically e-mail me when a page is not found).
You can use custom error pages for any error as long as you know its number (like 404 for page not found) by adding the following to your .htaccess file:
ErrorDocument errornumber /file.html
For example if I had the file notfound.html in the root direct
ory of my site and I wanted to use it for a 404 error I would use:
ErrorDocument 404 /notfound.html
If the file is not in the root directory of your site, you just need to put the path to it:
ErrorDocument 500 /errorpages/500.html
These are some of the most common errors:
401 - Authorization Required
400 - Bad request
403 - Forbidden
500 - Internal Server Error
404 - Wrong page
Then, all you need to do is to create a file to display when the error happens and upload it and the .htaccess file.
PLEASE READ THE WHOLE ARTICLE IN ITS HOME SITE:
http://www.freewebmasterhelp.com/tutorials/htaccess/1
- g
Last edited by mcsmom on Mon Oct 01, 2007 4:52 pm, edited 1 time in total.
"I was one of those who wondered why people would pay so much $$$$ to do something that was so much fun!" -R. Harkrider, Fortran Code Engr.
^If u read that in $GREEN, you clearly missed the HIGHLIGHTS!
http://www.joomlancers.com | http://www.joomlaconsultancy.net
^If u read that in $GREEN, you clearly missed the HIGHLIGHTS!
http://www.joomlancers.com | http://www.joomlaconsultancy.net
Re: FAQ: what is .htaccess ??
Another note for root level systems administrators is to not use .htaccess files at all. Control over specified directory access should be maintained via the apache directives configuration files. The above applies to shared server accounts that do not have access to server configured application configuration such as the /etc/apache2/sites-available/yoursite.conf, httpd.conf, apache2.conf... etc.. This applies to all top level applications. The .htaccess given via override (file based access directives) is designated to shared hosting resources only and not the preferred method.
Last edited by rjs on Tue Dec 13, 2005 1:21 pm, edited 1 time in total.
- guilliam
- Joomla! Enthusiast
- Posts: 159
- Joined: Thu Aug 18, 2005 10:27 am
- Location: Sunny City Cebu, Philippines!
- Contact:
Re: FAQ: what is .htaccess ??
@rjs, thanks for the added input.. hope my previous post didnt mislead on the lacking info.
- g
- g
"I was one of those who wondered why people would pay so much $$$$ to do something that was so much fun!" -R. Harkrider, Fortran Code Engr.
^If u read that in $GREEN, you clearly missed the HIGHLIGHTS!
http://www.joomlancers.com | http://www.joomlaconsultancy.net
^If u read that in $GREEN, you clearly missed the HIGHLIGHTS!
http://www.joomlancers.com | http://www.joomlaconsultancy.net
Re: FAQ: what is .htaccess ??
Oh, welcome. No, not at all. Great information and you might even sticky that one it's that good. Just wanted to point out that this does not pertain to those that have access to administrate a server, or at least not a preferred method.
Last edited by rjs on Mon Dec 12, 2005 11:04 pm, edited 1 time in total.
Re: FAQ: what is .htaccess ??
From upcoming:
Resources: Other Documentation
Apache Tutorial: .htaccess files
http://httpd.apache.org/docs-2.0/howto/htaccess.html
Article: Comprehensive guide to .htaccess
http://www.javascriptkit.com/howto/htaccess.shtml
Added
Article: .htaccess Tutorial
http://www.freewebmasterhelp.com/tutorials/htaccess/1
Thanks.
Another good one.
Resources: Other Documentation
Apache Tutorial: .htaccess files
http://httpd.apache.org/docs-2.0/howto/htaccess.html
Article: Comprehensive guide to .htaccess
http://www.javascriptkit.com/howto/htaccess.shtml
Added
Article: .htaccess Tutorial
http://www.freewebmasterhelp.com/tutorials/htaccess/1
Thanks.
Another good one.
“How do you know I’m mad?” said Alice.
“You must be,” said the Cat, “or you wouldn’t have come here.”
Help Me Please: Not able to download my htaccess file
I am trying to download my .htaccess file through JoomlaExplorer, FTP but not able to download it.
I am getting 'Failed to save 'C:\.htaccess' locally.' message when trying to download from FTP
I am getting 'Error internal server error forbidden message' when trying to download from JExplorer'
I have to edit this file as I am getting problem in Docman Configuration saving issue.
Please help me...
I am getting 'Failed to save 'C:\.htaccess' locally.' message when trying to download from FTP
I am getting 'Error internal server error forbidden message' when trying to download from JExplorer'
I have to edit this file as I am getting problem in Docman Configuration saving issue.
Please help me...
Re: Help Me Please: Not able to download my htaccess file
sunnyjey wrote:I am trying to download my .htaccess file through JoomlaExplorer, FTP but not able to download it.
I am getting 'Failed to save 'C:\.htaccess' locally.' message when trying to download from FTP
I am getting 'Error internal server error forbidden message' when trying to download from JExplorer'
I have to edit this file as I am getting problem in Docman Configuration saving issue.
Please help me...
You might try renaming the .htaccess file first to something like htaccess.txt and then download the file. You can then edit the htaccess.txt file and when done, upload it, rename it back to .htaccess.
Re: Help Me Please: Not able to download my htaccess file
newseed wrote:sunnyjey wrote:I am trying to download my .htaccess file through JoomlaExplorer, FTP but not able to download it.
I am getting 'Failed to save 'C:\.htaccess' locally.' message when trying to download from FTP
I am getting 'Error internal server error forbidden message' when trying to download from JExplorer'
I have to edit this file as I am getting problem in Docman Configuration saving issue.
Please help me...
You might try renaming the .htaccess file first to something like htaccess.txt and then download the file. You can then edit the htaccess.txt file and when done, upload it, rename it back to .htaccess.
Thank you... It has worked...
Thanks a lot
Re: FAQ: what is .htaccess ??
great help guilliam
Signature Rules: http://forum.joomla.org/index.php/topic,65.0.html