For example, you can redirect a website URL, allow or block access to certain IP addresses, and more
- How to identify the .htaccess file
In order to identify the .htaccess file, you will need to access your cPanel account.
Choose the File Manager option:
The next step is to select Settings and check if the Show Hidden Files (dotfiles) option is marked. Otherwise, only files that are not hidden will be displayed.
2. Crearea fișierului .htaccess
If the .htaccess file is missing and you want to create it, in the File Manager you will need to choose the File option:
Name the file .htaccess and choose Create New File:
Select the .htaccess file and click Edit:
Number of ways to use the .htacces file:
- Adding an IP in the websites whitelist
order deny,allow
deny from all
allow from 100.100.100.100 #100.100.100.100 is replaced with the desired IP
- Adding an IP in the websites blacklist
order allow,deny
deny from 100.100.100.100 #100.100.100.100 is replaced with the desired IP
allow from all
Note: The allow from all function will be specified to allow access to all IPs except the ones from deny.
- Redirect a domain from http: // to https: //
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
- Permanent redirect a domain to another domain
Redirect 301 / http://www.domain.tld/
- Redirect an old domain to a new domain
RewriteEngine on
RewriteBase /
RewriteRule (.*) http://www.newdomain.tld /$1 [R=301,L]
- Redirect a domain name from non-www to www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.domain.tld$
RewriteRule ^(.*)$ http://www.domain.tld/$1 [R=301]
Note: domain.tld is a way to exemplify a domain name.
Example of a domain.tld: easyhost.ro, google.com etc.
For more information on reliable hosting and the services we offer, please visit our homepage.
Comments
0 comments
Please sign in to leave a comment.