What is .htaccess

.htaccess is a configuration file for use on web servers running the Apache Web Server software. When a .htaccess file is placed in a directory which is in turn ‘loaded via the Apache Web Server’, then the .htaccess file is detected and executed by the Apache Web Server software. These .htaccess files can be used to alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software has to offer. These facilities include basic redirect functionality, for instance if a 404 file not found error occurs, or for more advanced functions such as content password protection or image hot link prevention.
.htaccess isn’t difficult to use and is really just made up of a few simple instructions in a text file.
If your .htaccess file does not work check weather mod_rewrite module is enabled or not in you web server.
1) Type <?php phpinfo(); ?> in a php file and save it and run that file in the server.
2) And now you can the list of information, just search the word “mod_rewrite” from the browser’s search menu
3) If it is found under the “Loaded Modules” section then this module is already loaded as you see in the picture below, otherwise find  the “httpd.conf” file under the “conf” folder inside the Apache’s installation folder. Now find  the following line “#LoadModule rewrite_module modules/mod_rewrite.so” in the “httpd.conf” file.
4) Remove the “#” at the starting of the line, “#” represents that line is commented.
5) Now restart the apache server.
6) You can see now “mod_rewrite” in the Loaded Module section while doing “phpinfo()”.
If your .htaccess file does not work in server , you should contact your system administrator or web hosting company and ensure they have enabled .htaccess within your account.

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:
(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.

Recommended Tutorials for you

Related posts

How to create custom error page using .htaccess

Anuj Kumar

How to make SEO friendly url using htaccess

Anuj Kumar

How to redirect website HTTP to HTTPS using .htaccess

Anuj Kumar


ashu January 28, 2019 at 10:42 am

please make a tutorial on rewrite module

Anuj Kumar January 28, 2019 at 5:32 pm

ok. I will post soon.

How to make SEO friendly url using htaccess - PhpGurukul.com November 11, 2018 at 5:58 pm

[…] previous tutorial we learned about what is .htaccess . In this tutorial I will explain how to make SEO friendly url using htaccess. Ex 1 : […]


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.