The .htaccess is a special file with dot as the first character. It is a server configuration file in Apache server to control the configuration settings. This file controls the configuration at subdirectory level which means you can have .htaccess file on each subdirectory to have different behavior for that directory. WordPress by default uses this .htaccess file to enable permalinks structure for your site. Most of the WordPress plugins like W3 Total Cache also use this file for enabling caching and compression. So as the important of this file, it is always necessary to edit the content to control the behavior of you WordPress site.
Problem in Viewing Htaccess File
The problem is being a file starting with dot (.), it is by default hidden on Windows and macOS. In our earlier article, we have explained how to view the hidden files in Windows operating system. In this article, we will discuss step by step method to view and edit .htaccess file in macOS.
This is useful for viewing your local MAMP installation as well as to view the file in FTP clients like FileZilla.
Step 1 – Check .htaccess File
Let us take an example from local WordPress installation on MAMP server. We could not find .htaccess file under “Applications > MAMP > htdocs” folder, because it is hidden by default on macOS.
You need to manually enable viewing hidden files on your Mac to view .htaccess file.
Step 2 – Open Terminal
On your Mac, press “Command + Shift” keyboard shortcuts to open Spotlight search box. Enter the keyword “terminal” and open the first application “Terminal”.
You can also open Terminal application through Launchpad. Click on the Launchpad, and look for “Terminal” app inside “Others” folder.
Step 3 – Execute Command to Make Hidden Files Visible
Enter the following command in Terminal and hit enter.
You will not see any success or failure message after executing the command. Unless, Terminal shows errors in the command you should assume it was executed successfully.
Step 4 – Relaunch Finder
Now hold option key and right click on the Finder application on your dock. Click on the last option “Relaunch” to close all your open Finder windows and relaunch again.
Step 5 – Check .htaccess File Again
Now navigate to the required folder, in our case we go to “Applications > MAMP > htdocs”. You can see all hidden files and folders including .htaccess file.
Step 6 – Editing Htaccess File
You can check out our separate article on how to edit htaccess file in live WordPress installation.
- Basically, open you FTP client like FileZilla and locate the folder you want to edit.
- Right click on the .htaccess file and choose “View/Edit”.
- This will open the file with default TextEdit app.
- Modify the content and save the file to upload back on the server.
if you want to edit the .htaccess file on your local installation then simply edit with TextEdit and save the file.
Step 7 – Again Hiding .htaccess and Other Files
Showing hidden files will display all the system files in all folders which may affect how you normally view your files. Therefore, it is a good idea to hide the files back after completing your task. Run the below command on Terminal to again hide all hidden files including .htaccess to return back to your normal view.
Leave a Reply
Your email is safe with us.