How to Create a .htaccess File
I like to tell you about the basics here on this show, as well as the advanced things. Creating a .htaccess file is some where in between.
The .htaccess file is a way to make a change to the configurations of your hosting account for each directory. For example, once you put a .htacess file in your public_html folder, on a Linux based hosting account, it will set the rules for that folder and all the folders created in it.
Here is everything you need to know…
Step 1 – Open up a text editor (such as Notepad or cPanel’s File Manager) and add in the lines you need and save the file.
Step 2 – Using the cPanel’s File Manager or your FTP client you will need to upload the file to the location you need it. This is usually inside of your public_html folder.
Step 3 – Rename the file to .htaccess, and save. It should be noted that .htaccess is the file extension. It is not filename.htaccess or yourpage.htaccess, it is just named .htaccess.
Truth be told, you really don’t need to know what the .haccess file is, as long as you can find the right snipits of code or “recipes” in it to get the job done. At least now you know how to create it… and knowing is half the battle.
How to Create a php.ini File
The php.ini file is a file that can be created to customize some of the configurations for your particular hosting account’s PHP setup. Some of the things you may be able to edit would be whether global variables are turned on or off, maximum allowed size for uploaded files, and more.
Your first step would be to open up a text editor (such as Notepad or cPanel’s File Manager) and add in the lines you need and save the file. Next, using the cPanel’s File Manager or your FTP client you will need to upload the file to the location you need it. This is usually inside of your public_html folder.
This link includes the php.ini directives you can set to configure your PHP setup.
Now, rename the file to php.ini, and save. To protect the php.ini file, you can add these lines to your .htaccess file:
- <Files .php.ini>
- order allow,deny
- deny from all
This way, it can not be displayed when somebody types in the file path into their browser. With some web hosts, in the .htaccess file, you will need to add the following line:
- suPHP_ConfigPath /home/username/public_html
Replace username with your actual cPanel user name. This will tell your account where your php.ini file exists. Other web hosts might have other rules when it comes to setting up the php.ini file for their hosting environment, so you might check with them to see what they recommend.