As you know the .htaccess file in a directory is a collection of instructions for your web server mainly Apache or NGINX. The web server have various configurations how to handle files and how to deliver the files to websites. But in case you want to configure or change the way web server serve static resources or permalinks you may instruct web server like Apache via .htaccess file. This way your main web server configuration stay untouched and that configuration works only for specific directory. In some cases you may need to disable .htaccess file for testing purposes or if website is slowing down cause of some faulty rule in your .htaccess file. The best way to test problem with .htaccess file is by disabling it.
As if you want to disable PHP file execution in some directories of your web server. For example in case you are using a folder where uploads are stored and they all should be images or PDF files. To extend security of your website you may disable PHP execution on such directories using .htaccess rules.
What is the .htaccess file used for on your web server?
If you want to configure your web server on directory basis .htaccess file or “distributed configuration files” provides a way to make those configurations. As most of web servers host multiple websites that’s why directory based configurations do not conflict from one website to another website. And the configurations you define in .htaccess file only work on the directory and its sub directories where you have defined .htaccess file with rules.
While there are many configurations you may find in Apache HTTP service documentation. But mostly the .htaccess files are used to handle the cache rules, permalinks in WordPress or another framework. Some of the basic usages of .htaccess files are listed below.
- Add redirections for certain URLs
- Load custom error pages, like 404 pages
- Force your site to use HTTPS instead of HTTP’
- Disable access to certain directories or execution of scripts
- Password-protect certain directories on your server
- Prevent hotlinking
- Add leverage browsing cache to your website
- cPanel also use .htaccess file to change PHP Version on directory basis.
So why do you need to disable .htaccess file?
There are some cases if you believe your website’s performance is not good or there is a certain rule which is reducing the performance of your website. In some cases as WordPress adds rules in .htaccess file for permalinks you may need to reset them? So by disabling the .htaccess file you can re generate permalinks or anything.
Your website maybe have been attacked and a malware have been detected in .htaccess code. These are some cases where your website may need to disable .htaccess file. Remember the wrong rules can reduce the performance and speed of your web server. So before editing or adding any rule in your .htaccess file you should know what you are doing.
- You may need to reset your WordPress permalinks?
- Are you looking for better website performance? Check WordPress speed optimization service.
- Maybe you can hire a WordPress Assistant.
Important: If you disable .htaccess file in a directory and parent directory have a .htaccess file then its rules will be applied.
How to disable .htaccess file on your web server?
First of all you need access to your web server files via FTP or File Manager. Whatever is your preferred way you can access .htaccess files in both ways. Then you can just rename your .htaccess file to something like .htaccessBACKUP or anything else it will be disabled then. As there are two ways to disable .htaccess files let’s cover them one by one.
Disable .htaccess file via FTP
For this method you would need access to your web server’s FTP Account. Which includes a hostname, username and password and in some cases the port if its not default 21 port. So I assume you have this information let’s go forward.
- Login your FTP Account using FTP credentials using a FTP Client like FileZilla
- Locate the directory where you want to disable .htaccess file
- Right click and rename it
Done you have disabled .htaccess file successfuly!
Disable .htaccess file via cPanel File Manager
Login your cPanel account and access the file manager. By default dot files (.) are hidden in cPanel file manager. Before renaming or finding the file you need to enable to show hidden files.
- Sign in your cPanel account
- Go to File Manager from Files section
- Open the directory from where you want to disable .htaccess file
- If there is no .htaccess file click on settings on top right
- Check Show Hidden Files (dotfiles) option and save
- Right click on .htaccess file and rename it
That’s it you have now disabled the .htaccess file via cPanel File Manager.
How to enable .htaccess file on your web server?
It’s just reverse engineering you can rename your .htaccess file back to .htaccess and its enabled again. Your server will start taking instructions again from .htaccess file. You should remember that the correct file name for .htaccess is required otherwise it will not work and will remain disabled.
Conclusion
While .htaccess is a powerful file which configure your web server with your given rules related to redirection, https or permalinks and leverage browsing cache. But the wrong configuration can reduce the performance of your website. So always make sure what you are doing. If you are facing reduce server response time problem you may hire a PHP developer.
1 Comment