How to Create htaccess File
Before learning how to create htaccess file, let’s first of all define it. What is .htaccess? In simple term, it’s a configuration file used by web servers running on Apache Web Server software.
Second, how does it work? Again, in simple term – you place the .htaccess file in a particular folder (or directory) under Apache’s web directory structure. When the said folder/directory is accessed via a web browser, the .htaccess file is detected and read to execute its contents/directives.
So basically, the .htaccess file is a configuration file used to tell the web server to do certain things as it pertains to the website the web server is serving. These include but not limited to tasks like redirecting website visitors from one page/folder to another, denying website visitors by their IP address or referring agent, password protecting certain pages/folders, forcing media files to be automatically downloaded instead of displayed on the browser and a whole lot more.
That being said, a lot of people don’t know how to create htaccess file and that’s what this write up is all about – to show you how to easily and effortless how to create htaccess file.
How to Create htaccess File:
You can create htaccess file on your local computer and then upload it to the web server or you can create it directly on the web server itself.
On your local computer:
Using Windows: Start a simple editor such as “Notepad”, when it starts, click on “File” menu and select the “Save As” option from the drop down menu. On the save as prompt that appears, make sure that the “Save as type:” drop down option is selected to “All Files” and then type in “.htaccess” – without the quotes “” of course. And that’s it. You’ve created htaccess file on Windows.
Using Mac OS X: Open up TextEdit and and then type in “.htaccess” – without the quotes “” of course. And that’s it. You’ve created htaccess file on Mac OS X.
On the web server:
If you’re web server is running cPanel/WHM control panel:
- Log into your cPanel account.
- Navigate to the File Manager section
- Click on the + File menu option at the top left hand corner
- Type in “.htaccess” – without the quotes “” of course as the new file name
- Specify the folder you want the new file placed in
- Click on the Create New File button
And that’s it. You’ve created htaccess file on your web server via the control panel.