htaccess Tutorials
How to Restrict Access to Directories by IP Address
Last Updated: January 5, 2025To secure your admin area from hackers, you should only allow access to your admin directory from selected IP addresses. You can create a dot htaccess file in the directory where you want to restrict access to specific IP addresses. For example, if you have a WordPress blog installed on your main directory and you...
Fix PHP Error: Allowed Memory Size of X Bytes Exhausted
Last Updated: January 5, 2025If you are getting an error such as “Allowed memory size of… in file /directory/folder/yourscript.php“, you can use an htaccess file to resolve this problem. If the error does not go away even after applying the htaccess code, you should contact us. We will do our best to help you. Place this code in the...
PHP Error: Allowed Memory Size of x Bytes Exhausted
Last Updated: January 5, 2025If you are getting an error such as “Allowed memory size of… in file /directory/folder/yourscript.php“, you can use an htaccess file to resolve this problem. If the error does not go away even after applying the htaccess code, you should contact us. We will do our best to help you. Place this code in the...
How to Set the PHP Version per Directory in cPanel
Last Updated: January 5, 2025Do you want to use different PHP versions per directory? You can do this using cPanel and the dot htaccess file. 1. Log in to your cPanel account. 2. In the Software section, click on MultiPHP Manager. 3. The first thing we need to do is to get the code generated by cPanel. 4. Scroll...
How to Edit (Dot)htaccess File in the cPanel File Manager
Last Updated: January 5, 20251. Log in to your cPanel account. 2. In the Files section, click on File Manager. 3. Navigate to the directory where your dot htaccess file is located. To edit the .htaccess file of your root directory, navigate to the public_html directory. 4. If the .htaccess file is not visible, click Settings in the top...
How to Ban Any IP Address via htaccess
Last Updated: January 5, 2025If you want to block an IP Address, you can add the below lines to your htaccess file. order allow, deny deny from IP-ADDRESS allow from all Replace IP-ADDRESS with the IP you want to block.
How to Disable Directory Browsing Using the htaccess Rule
Last Updated: January 5, 2025For security purposes, you should disable directory browsing on your website so no one can see the files/directories of your website. You can disable Directory Browsing by adding the below line to your dot htaccess file. Options -Indexes
How to Protect Your htaccess File
Last Updated: January 5, 2025You can prevent unauthorized access to your htaccess file by adding this rule to the file: # .htaccess protection order allow, deny deny from all satisfy all
How to Create a User-friendly URL Using htaccess
Last Updated: January 5, 2025If your website is using a long URL such as example.com/files/folder/sitemap.html, you can change it to “example.com/sitemap” using htaccess. Modify this line according to your needs, and then add this code to your htaccess file. RewriteEngine onRewriteRule ^sitemap/$ /files/folder/sitemap.html [L]
How to Redirect a Page or Website Using htaccess
Last Updated: January 5, 2025If a page on your website no longer exists and you want to redirect it to a new page or website, you can use the dot htaccess file to redirect visitors. Redirect from a page/directory to another domain or the main domain: Redirect from a specific page to a domain:RewriteEngine onRedirect 301 /mypage.html http://example.com Redirect...
How to Block Any IP Address via an htaccess Rule
Last Updated: January 5, 2025If you want to block an IP Address, you can add the below lines to your htaccess file. order allow, deny deny from IP-ADDRESS allow from all Replace IP-ADDRESS with the IP you want to block.
How to Disable Directory Browsing Using the htaccess Rule
Last Updated: January 5, 2025For security purposes, you should disable directory browsing on your website so no one can see the files/directories of your website. You can disable Directory Browsing by adding the below line to your dot htaccess file. Options -Indexes
How to Protect the htaccess File
Last Updated: January 5, 2025You can prevent unauthorized access to your htaccess file by adding this rule to the file: # .htaccess protection order allow, deny deny from all satisfy all
How to Create a User-friendly URL Using htaccess
Last Updated: January 5, 2025If your website is using a long URL such as example.com/files/folder/sitemap.html, you can change it to “example.com/sitemap” using htaccess. Modify this line according to your needs, and then add this code to your htaccess file. RewriteEngine onRewriteRule ^sitemap/$ /files/folder/sitemap.html [L]
How to Redirect a Page to Another Page or Website Using htaccess
Last Updated: January 5, 2025If a page on your website no longer exists and you want to redirect it to a new page or website, you can use the dot htaccess file to redirect visitors. Redirect from a page/directory to another domain or the main domain: Redirect from a specific page to a domain:RewriteEngine onRedirect 301 /mypage.html http://example.com Redirect...