ht access file

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
.htaccess is primarily a security settings file, determining who has access to the folder/directory (and its subdirectories). It is also used for determining how to handle errors (custom error pages may be used in the place of the server's default pages) and set the MIME types (and processing parameters) for various file extensions.

In SEO terms, it's used most often for URL rewriting for database-driven web applications. Normally, a page in a CMS would be accessed using the display script's filename and one or more data parameters, like this:

Code:
http://www.example.com/index.php?page_type=blog&title=blog_entry_title&date=2013_02_07

That's not particularly user-friendly. And somewhere back in the long, long ago, search engines wouldn't list the individual pages properly since the URLs all point to the same file. That's not really a problem anymore, at least to the search engines. "SEO-friendly" URLs really aren't any better for SEO than the app's native URLs, but they're far from user-friendly, and if you want real people to link to you (especially with bare URLs in emails and so forth), then you'll want something that makes sense to the user, not to a computer. URL rewrite rules will allow you to use links that look like this:

Code:
http://www.example.com/blog/2013/02/07/blog_entry_title

Ordinarily, that would force the web server to look in a directory named "blog" for a directory named "2013", then look in there for a directory named "02", then for a directory named "07", then for a directory named "blog_entry_title", and look in there for a file named index.html or index.php. The .htaccess file will take the pretty URL and rewrite it to look like the ugly URL, so the user gets the index.php page with all of the data parameters filled in (although the browser's address bar still has the pretty URL in it). Again, it doesn't matter to the major search engines anymore (they understand all of the major and most of the minor CMS internal structures and can tell which parameters matter), but it does make a big difference to humans.

There are several references and tutorials on the web to help you wade through all of the functions and options available in the .htaccess file. Some of them use regular expressions, which can sometimes be difficult to understand at first. And the order of application of the rules you write matters a lot, so it can be tricky to get right until you understand. There's much more to it than can be easily fit into a forum posting (several long-form web pages worth, in fact), so seek out the tutorials (especially the ones at apache.org).
 

hostsingh

Banned
Messages
21
Reaction score
0
Points
0
A .htaccess file is a directory-level configuration file supported by several web servers. It allows for decentralized management of web server configuration. .htaccess file should be placed in root directory of site.
 

rajdeep01

Banned
Messages
66
Reaction score
0
Points
0
The htaccess file is a configuration file which is used on Apache based web servers to control many features of the server. The first thing you need to do is find out if your host actually lets you edit htaccess files. Because of security problems which can arise, many hosts stop their customers from editing it the .htaccess file. Therefore you should check the Frequently Asked Questions area of your host to see if you have permission to edit the file.
 
Top