Need to check, edit, or replace the .htaccess file on your WordPress website? We assume you want to block a specific IP address from accessing your website or some sections. Or, are you, perhaps, rewriting URLs or altering the structure of permalinks? Setting up permanent (301) redirects or trying to force SSL (Secure Sockets Layer) to transition from HTTP to HTTPS? Whatever the case may be, the file is undoubtedly important. It’s so significant that many hosting providers keep it hidden to prevent newcomers from messing with it unless they know what they’re doing. Since we presume you do, here’s how to access the .htaccess file in WordPress.
Warning. No matter how small the change you plan is, and despite the fact you can always replace the contents with a default WordPress .htaccess file, you should create a backup of your website. There’s no need to risk losing changes made so far.
1. Getting access to the .htaccess file via cPanel
As usual, we start with the method that requires the least effort and advanced knowledge. You also don’t need help from third parties, i.e., custom changes, software, or WordPress plugins. cPanel, short for Control Panel, is something your web hosting installs for you and makes accessible on their website. You’ll get the login credentials via e-mail, though you’re usually required to change the auto-generated password manually. With login details in hand, do the following:
- Sign in to the cPanel on your web hosting website.
- On the main menu, head over to the File Manager option, typically under “Files” or “Popular Links”. This can vary based on alterations to cPanel.
- Head over to the public_html folder. It may be named root or htdocs or be inside those directories.
- Find the .htaccess file on the list. It will be among file extensions such as .html, .shtml, .txt, and .php and ext to folders such as “wp-content” and “wp-includes”.
- Right-click on .htaccess and select View/Edit or only Edit.
- The file will open in a text editor, letting you add snippets and other modifications. Save changes when you’re done.
How to make .htaccess appear in cPanel
As we mentioned, some web hosting providers purposefully conceal .htaccess to prevent inexperienced owners from tampering. Steps to make them show is specific to the Control Panel they use. For instance, in the default cPanel, you need to:
- Click on Settings in the top right corner of the “File Manager” window.
- Optional. Select Document Root and the domain name of your website.
- Put a checkmark in front of Show Hidden Files (dotfiles).
- Select Save. You may have to reopen the “File Manager” window to see the .htaccess file displayed.
2. Gain access to WordPress .htaccess file through FTP client
Don’t like accessing your website through a web page, or planning to make extensive changes that require frequent sign-ins or large uploads? Don’t fret, there’s an alternative, though it requires you to select and install one of many leading FTP clients. They may have a different user interface and specific features, but the basics remain the same. You’ll need to:
- Check the e-mail you got from your hosting when signing up. If it doesn’t contain FTP account information:
- Head over to the cPanel and select the FTP Accounts option under “Files”.
- See if there’s an existing account. If there isn’t, set one up with a username, password, hostname, and port. You want to use port 21 for FTP and port 22 for SFTP.
- Launch the FTP client of your choice and connect to the server using the aforementioned credentials, usually from the main menu.
- Head over to the folders we mentioned in the previous method, precisely step 3.
- Find the .htaccess file inside and right-click on it to select Edit or View/Edit, which varies from client to client.
Note. If the .htaccess file is missing, it’s likely hidden, like in method 1. Making it appear in FileZilla is as easy as clicking on Server in the main menu, then selecting Force showing hidden files from the drop-down list. Check the exact steps for your FTP client.
3. Utilize a .htaccess editor WordPress plugin
Although WordPress has a built-in editor for a variety of HTML, CSS, and PHP files, .htaccess has no file extension. Moreover, security is pivotal for the reasons we mentioned. Thus, you won’t find an option to edit a .htaccess file built into WordPress. Unsurprisingly, the next best alternative is to find plugins that let you.
Using a plugin for SEO (Search Engine Optimization)? If so, do this
If you utilize one of many available SEO-oriented plugins, especially the better-known ones, they oftentimes offer a way to modify this file in particular. For instance, you can follow these instructions to get access to the .htaccess file via the Yoast SEO WordPress plugin:
- Access your WordPress Admin Section.
- In the sidebar on the left side, select SEO.
- When it expands, go to Tools.
- Find and click the File editor link on the list of Tools Yoast SEO provides.
- You can now see the contents of your .htaccess and edit it.
- Click the Save changes to .htaccess button after you’re finished.
We’ll cover troubleshooting separately, but for the File editor to appear, you must turn on file editing in WordPress. Moreover, if you get a “.htaccess file is not writable” error, you need to sort out file and folder permissions (644 for files, 755 for directories/subdirectories).
Installing a dedicated plugin for editing .htaccess
Not a user of SEO plugins, or can’t find your way around options and/or the error? Not an issue. You can still get a plugin designed for this specific purpose. These also come with file backup, failsafe features, and syntax analysis. Follow these steps to access WordPress .htaccess file through a dedicated plugin:
- Install and activate a WordPress plugin from the repository suitable for this purpose. We’ll use Htaccess File Editor for demonstration, though we’re in no way affiliated.
- In the Admin Dashboard sidebar on the left, click on Tools.
- Select WP Htaccess Editor.
- Make changes to the file and click on Test Before Saving.
- If everything is right, click on Save Changes.