How to Fix the WordPress .htaccess File (Beginner’s Guide)
Your web site’s .htaccess file is a tiny however necessary file that runs behind the scenes and acts like a set of directions on your server.
The file tells how you can deal with issues like permalinks and safety measures. Sadly, this file can get corrupted for numerous causes, resulting in points like damaged hyperlinks or a white display screen of loss of life.
Our expertise within the WordPress trade has taught us that enhancing the file will be tough, particularly for rookies. However don’t fear, we’ll train you how you can entry the file simply and make adjustments to resolve any concern.
On this article, we’ll stroll you thru how you can repair the WordPress .htaccess file.
Here’s a fast overview of all the things we’ll cowl on this information. You possibly can click on the hyperlinks under to leap to any part:
What Is the .htaccess File?
The .htaccess file is a hidden configuration file that performs a significant position in how your WordPress website operates. It’s basically a set of directions for the Apache net server, the software program that’s usually run by your WordPress internet hosting.
Certainly one of its core features is creating user-friendly URLs on your weblog posts and pages. These are the clear and descriptive addresses you see in your browser bar as an alternative of lengthy, cryptic strings.
You may as well use a .htaccess file to arrange safety measures like password-protecting sure directories or blocking entry makes an attempt from suspicious IP addresses.
In addition to that, some plugins use .htaccess to implement caching, which may enhance your site’s loading speed.
That stated, let’s take a look at a number of the indicators that’d inform your .htaccess file wants fixing.
Easy methods to Inform If Your .htaccess File Is Corrupted
The .htaccess file would possibly turn into corrupted for a number of causes. It might be because of a plugin battle, unintended edits, or perhaps a server glitch.
Listed here are some indicators you would possibly discover in your WordPress website that counsel the .htaccess file is damaged:
- Damaged hyperlinks: A broken link happens when the consumer just isn’t taken anyplace, or they see unusual error messages.
- White display screen of loss of life: That is when your web site shows nothing however a clean white display screen.
- Plugins not working correctly: Some plugins depend on particular directions within the .htaccess file to perform accurately, however because of an error, they don’t carry out as they’re supposed.
Now, let’s take a look at other ways you may entry and edit the .htaccess file in WordPress.
Easy methods to Entry and Repair .htaccess File in WordPress
The .htaccess file is situated within the root directory of your web site. There are other ways to entry and edit the file.
For example, you need to use the internet hosting supplier’s cPanel and entry the file utilizing the File Supervisor. You may as well connect with your website utilizing an FTP shopper and think about completely different recordsdata and folders. One other approach is to make use of a plugin to view and edit the .htaccess file content material.
Professional Tip: Earlier than enhancing the .htaccess file, it’s greatest to create a backup of your WordPress web site. This fashion, you may simply restore it if something goes fallacious. For extra particulars, please see our information on how to back up a WordPress website.
Let’s take a look at every of those strategies intimately.
1. Repair .htaccess File utilizing File Supervisor or FTP Shopper
For those who’re unable to entry the WordPress dashboard, then you need to use a File Supervisor or FTP service to find the .htaccess file.
To start out, you may open cPanel of your WordPress internet hosting service. For instance, in Bluehost, you may open the web site settings.
After that, you’ll want to modify to the ‘Superior’ tab.
From right here, scroll right down to the ‘cPanel’ choice and click on the ‘Handle’ button.
As soon as the cPanel opens, you may navigate to the ‘Recordsdata’ part.
Go forward and click on the ‘File Supervisor’ choice.
Subsequent, you will notice completely different recordsdata and folders in your web site.
The .htaccess file is situated within the public_html folder. Merely open the folder from the menu on the left and scroll down to seek out the .htaccess file.
You possibly can then right-click the .htaccess file and choose the ‘Edit’ choice to repair any points.
Be aware: For those who can’t discover your .htaccess file, then see our information on how to find the .htaccess file in WordPress.
Subsequent, a popup will open, warning you to again up the unique file earlier than enhancing. Go forward and click on the ‘Edit’ button.
On the following display screen, you will notice the .htaccess file editor.
Right here, you may make adjustments and repair the file. For instance, you may examine for any typos, incorrect syntax, or incompatible code that may trigger errors.
Alternatively, utilizing an FTP (file transfer protocol) client is an alternative choice for accessing the file.
Yow will discover the file within the root listing. Merely right-click the .htaccess file and click on the ‘View/Edit’ choice.
For those who haven’t used FTP earlier than, then please see our information on how to use FTP to upload files to WordPress.
Subsequent you may edit the file in notepad software program in your pc.
When you’ve fastened the .htaccess file, you may add it again to the basis listing utilizing the FTP service.
2. Repair the .htaccess File Utilizing a Plugin
For those who’re capable of view the WordPress dashboard, then one other approach of accessing and enhancing the .htaccess file is through the use of a plugin like All in One SEO (AIOSEO).
It’s the best SEO plugin for WordPress. It helps you optimize your website for search engines like google with none technical information. The plugin affords numerous instruments, together with a robots.txt editor, a .htaccess editor, database instruments, and extra.
To start out, you’ll want to put in and activate the AIOSEO plugin. For those who need assistance, then please see our information on how you can set up a WordPress plugin.
Upon activation, you will notice the welcome display screen and AIOSEO setup wizard. Merely click on the ‘Let’s Get Began’ button and observe the onscreen directions.
For extra particulars, please see our information on how to set up All in One SEO for WordPress correctly.
Subsequent, you may head to All in One search engine marketing » Instruments from the WordPress admin panel and change to the ‘.htaccess Editor’ tab to edit the file’s contents.
When you’ve made adjustments and glued the file, merely click on the ‘Save Modifications’ button on the high.
Frequent Points to Repair in WordPress .htaccess File
Now that you already know the place to seek out the .htaccess file and how you can edit it, let’s take a look at completely different points you may repair within the file.
1. Fixing 500 Inside Server Error
A 500 inside server error in WordPress is a common error message that signifies the server encountered an surprising drawback and couldn’t fulfill your request. It’s like a cryptic message out of your web site saying one thing went fallacious, however it doesn’t give particular particulars about what.
The error message additionally seems to be completely different relying on the net server software program (Nginx or Apache) your website makes use of. For instance, right here’s the way it seems to be when utilizing Ngnix and Google Chrome.
This error will be attributable to a corrupted .htaccess file. You possibly can repair the error by changing the present file with a brand new one.
Merely entry your web site’s root folder utilizing an FTP shopper. Then, rename the present .htaccess file so it’s out there as a backup and WordPress can’t acknowledge it. After that, create a brand new file within the listing and identify it a ‘.htaccess’ file.
Now, open the brand new file and edit it.
Go forward and enter the next code within the file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
For extra particulars, please see our full information on how to fix the 500 internal server error in WordPress.
2. Fixing Error Too Many Redirects Challenge
The ‘Error too many redirects’ often happens because of a misconfigured redirection concern in WordPress. This results in a redirection loop, and also you’ll see this error within the net browser.
One of many to repair this concern is by resetting the .htaccess file within the root listing.
First, you’ll want to go to the basis listing of your website utilizing an FTP shopper or File Supervisor. Subsequent, find the .htaccess file and delete it. Now, strive visiting your web site to see if the redirect error is fastened.
Because you simply eliminated the .htacess file, you’ll must recreate it. WordPress routinely creates one for you. To ensure it does, merely go to the Settings » Permalinks web page from the WordPress dashboard and click on the ‘Save Modifications’ button on the backside.
To be taught extra methods to repair the problem, please see our information on how to fix error too many redirects issue in WordPress.
3. Fixing Posts Returning 404 Error
One other concern you may repair via the .htaccess file is the posts returning 404 errors. Normally, a corrupted or lacking .htaccess file may cause this error.
To resolve this concern, you’ll must replace the file from the basis listing and alter the file permissions. Merely find the file utilizing an FTP shopper, right-click the file, after which choose the ‘File permissions’ choice.
Subsequent, you will notice completely different settings to vary for the .htaccess file.
Go forward and make the file writeable by altering its permissions and getting into ‘666’ into the ‘Numeric worth’ field. As soon as that’s accomplished, click on on the ‘OK’ button.
For extra methods to repair the problem and full steps, it’s possible you’ll wish to see our information on how to fix WordPress posts returning 404 error.
There are a lot of different errors that may happen in your website, and also you would possibly want to repair the .htaccess file. See our full listing of the most common WordPress errors and how to fix them.
Bonus: Rent a WordPress Assist Company
Working with a .htaccess file will be tough as a result of it generally entails enhancing code, and accessing the file will be disturbing for rookies.
That is the place a WordPress maintenance and support agency may help you out. You possibly can rent WordPress specialists who can repair the .htaccess file and deal with all the things for you.
For instance, we provide Premium WordPress Support Services. For a one-time payment, our specialists can repair errors and different points in your web site, together with issues with .htaccess.
Alternatively, if you’re on the lookout for ongoing assist, then our WPBeginner Pro Maintenance Services might be a greater match.
We now have over 16 years of expertise, having helped 100,000+ customers with WordPress and fixing their websites.
Our crew of execs is obtainable 24/7 to make sure your website features correctly. We’ll examine whether or not the .htaccess file is accurately configured or what must be fastened in order that your guests have an important web site expertise.
Additionally, you will get entry to core upkeep duties like backups, safety updates, plugin troubleshooting, theme customization, and on-demand help.
You may as well get different providers on your WordPress web site. See our full listing of WPBeginner Pro Services.
Extra Assets for the WordPress .htaccess File
We hope this text helped you discover ways to repair the WordPress .htaccess file. You might also wish to see our information on eCommerce maintenance tips and our knowledgeable decide of the best WordPress support agencies.
For those who preferred this text, then please subscribe to our YouTube Channel for WordPress video tutorials. You may as well discover us on Twitter and Facebook.