Website security is an important need for any business, as the user will have a safe environment in the website. Many websites uses HTTP and HTTPS versions which may lead to SSL warnings. SSL certificate is essential for creating SSL connection and the certificate is provided by CA (Certificate Authority). Chrome and Firefox browsers shows warning without SSL Certificates. If SSL is not used in the website, then it will not be safe. Accessibility or PCI Compliance is necessary for secure encrypted connections using SSL. Once a SSL certificate is installed and the site can be reached through HTTPS, then the visitors can access should access the appropriate site or web page automatically. It is very important to redirect HTTP to HTTPS. While using HTTPS in the browser, codes in the .htaccess has to be edited. The following steps are used to edit the .htaccess files.

Editing .htaccess File

There are directives in the .htaccess file that specifies the working of the server and it affects the working of the functions. Redirects and Rewriting URLs are the directives in .htaccess file. The methods of editing an .htaccess file is given below:
  • File is edited on the computer and it is uploaded to the server using FTP.
  • To edit a file remotely “Edit” mode is used in FTP program.
  • Text editor and SSH is used to edit a file.
  • File Manager in cPanel is used to edit the file.
Editing .htaccess file in cPanel File Manager:
  • Login cPanel.
  • Goto File in that select "File Manager" and in File Manager select public_html folder.
  • Now Check “Show Hidden Files (dotfiles)”.
  • Click Go option.
  • A new window is opened .htaccess file is viewed.
  • Right click on .htaccess and in menu option select Code Edit.
  • A dialog box is popped up that asks about encoding. Click Edit button to continue.
  • Edit the file.
  • Click “Save Changes” option after editing.
  • The website has to be tested to check the changes. If there is any error, the previous version is restored and the process is made again.
  • After finishing the process, close the window by clicking “close” option.
Redirecting HTTP to HTTPS:

Redirecting Web Traffic:

At first .htaccess file is created in the public_html folder. Add following to the existing .htaccess code.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$$1 [R,L]
If .htaccess file already exist, do not duplicate the RewriteEngine On. Lines beginning with RewriteCond and RewriteRule should follow RewriteEngine On which already exist.

Redirect Only a Specific Domain

To redirect a specific domain add the following commands

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$$1 [R,L]
Your domain can be replaced by the actual domain name and in case of the folder, actual folder name is replaced.

Redirect Only a Specific Folder

To redirect a specific folder add following commands

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$$1 [R,L]
First release
Last update
0.00 star(s) 0 ratings