Best Wordpress themes and plugins

How to Edit the .htaccess File in WordPress?

WordpressComp -
How to Edit the .htaccess File in WordPress?
Rate it!
Rate this post

Easy methods to Edit the .htaccess File in WordPress? obtain the WordPress Theme

Obtain now Easy methods to Edit the .htaccess File in WordPress? theme.
Evaluate and opinions of The best way to Edit the .htaccess File in WordPress? theme.


The htaccess file is a configuration file that’s situated within the root of your WordPress set up. This file can be utilized to override the general settings of your WordPress set up, htaccess is an abbreviation of time period ‘Hypertext Entry’. There’s a interval that precedes the file identify ‘htaccess’ which merely means it’s a hidden file. You aren’t more likely to see htaccess file in your browser.

You possibly can implement quite a few changes on your site by modifying htaccess. The modifications embrace; redirecting URLs, defending your photographs from hotlinking, stopping entry to website folder or blocking IPs from accessing your website.

On this publish, we’ll take a look at the way to edit htaccess and the way you need to use htaccess to override the opposite settings in your website.

Desk Of Contents

1 Precautions of Modifying htaccess

When you’re modifying htaccess it’s essential to train most warning since errors on .htaccess file will trigger your website to crush. Finding the htaccess can be troublesome; listed here are two precautions to information you once you edit htaccess:

  • Present Hidden Information – when modifying htaccess within the cPanel, you’ll want to verify the setting ‘Present Hidden Information’ so that you can view and edit htaccess. In some web hosting you could be required to vary the permission settings to view the htaccess file.
  • Backup htaccess – making a backup copy of the htaccess file is an important precaution when modifying htaccess file. This backup copy is used to revive again the location to the unique standing if one thing goes flawed when modifying htaccess file.

2 Methods to Edit WordPress htaccess File

WordPress htaccess file includes of directives to your server on tips on how to deal with numerous situations. These directions to the server could have a direct impression in your web site.

It’s, subsequently, mandatory you train most warning when modifying htaccess to stop crushing your web site. The most typical directions you will see in a WordPress htaccess file are redirects and rewriting of URLs. WordPress has a set of directions on the htaccess that management how WordPress websites behave. The essential htaccess in WordPress include the next content material:

Primary WordPress htaccess

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ – [L]
RewriteRule . /index.php [L]

# END WordPress

three Understanding Contents of htaccess

WordPress primary htaccess accommodates various strains of code and you can even add your personal directions to control Apache server in your internet hosting. Earlier than you’ll be able to write any guidelines, it is vital you start by understanding what these strains of code imply. There are directions and feedback within the htaccess; the latter helps you perceive directions to the server. The opposite strains of code are directions to the server on how you can perform sure features.

four Writing htaccess Feedback

Once you take a look at htaccess file you’re more likely to see strains which might be preceded by a hash signal. These strains are referred as feedback and as said above they allow you to perceive the code.

Writing feedback in htaccess requires you so as to add a hash signal (#) earlier than you write the remark. Listed here are two examples of htaccess feedback:

# Redirects 301

# 404 Errors Pages

5 Methods to create htaccess File in WordPress

You’ll be able to create htaccess by merely opening a textual content editor and including the content material of htaccess and saving the file as .htaccess. When you don’t have a htaccess in your website, you possibly can create one and add it to your server via the cPanel or FTP shopper.

6 Methods of Modifying htaccess File

There are alternative ways you need to use to edit .htaccess file that embrace:

  • cPanel .htaccess edit
  • WordPress Dashboard .htaccess edit
  • FTP Shopper .htaccess

The quickest solution to edit .htaccess file is thru the cPanel, this text will clarify every of those methods of modifying .htaccess.

7 The right way to Edit htaccess File from cPanel

It’s attainable to simply edit .htaccess out of your internet hosting cPanel. Earlier than you possibly can edit the .htaccess in your internet hosting cPanel, you could find it first. Listed here are the steps you must take:

  • Log into internet hosting cPanel
  • Find the File Supervisor or Information Icon as proven under:

<img class="aligncenter measurement-full wp-picture-124294" Edit WordPress .htaccess

  • Click on the choice to view the Doc Root for the area you need to edit .htaccess
  • Select the choice to proven hidden information.

<img class="aligncenter measurement-full wp-picture-124295" Edit WordPress .htaccess

  • If you open the File Supervisor, find the .htaccess file and proper click on on it to edit.

<img class="aligncenter measurement-full wp-picture-124296" Edit WordPress .htaccess

  • Copy the contents of the .htaccess earlier than you start modifying and save a backup copy.
  • Open the htaccess file after making a backup and add your directions. Save the file and refresh your website to verify for the modifications.

eight Methods to Edit htaccess file from WordPress Dashboard

Modifying htaccess from the dashboard is one of the best answer when you should not have FTP entry or cPanel logins. There isn’t a inbuilt WordPress function that lets you edit htaccess from the dashboard. However, there are plugins which are used for modifying WordPress htaccess from the dashboard.

WP Htaccess Editor is the perfect plugin for modifying htaccess from WordPress dashboard. This plugin is superior because it additionally has a function to permit you to restore a backup simply improve something goes mistaken.

WP Htaccess Editor Plugin is free and could be downloaded from WordPress repository. To edit htaccess from WordPress dashboard, install this plugin and activate it.

<img class="aligncenter measurement-full wp-picture-124298" How To Edit WordPress .htaccess File One other plugin that has htaccess edit performance is Yoast SEO. Yoast search engine optimization is the preferred WordPress search engine optimisation plugin, when you have it put in go to instruments on the primary menu and File Editor.

It is best to guarantee you might have enabled Superior Options.

On the htaccess editor you’ll be able to add any directions as proven within the picture under:

<img class="aligncenter measurement-full wp-picture-124299" Edit WordPress .htaccess File

After making the modifications to your htaccess file and save your modifications and go to your website to see the modifications.

9 Learn how to edit htaccess file from FTP Shopper – Filezilla

Modifying htaccess file from FTP requires you to first login to your File Switch Protocol shopper like Filezilla. The FTP logins may be obtained out of your internet hosting cPanel the place it’s also possible to reset the password.

The most typical problem when modifying htaccess from FTP shopper is finding the htaccess.

You need to navigate to the server on the primary menu and make sure the ‘Pressure Displaying Hidden Information’ choice is checked.

After finding the htaccess file obtain it and make a backup copy earlier than you’ll be able to start modifying it.

10 Helpful Tips for modifying htaccess

As talked about above, there are a selection of guidelines which you could implement within the htaccess to vary how your WordPress website works. I’ll clarify how you can implement every of those guidelines in your htaccess file.

eleven Primary WordPress htaccess Edit

When you’re modifying WordPress htaccess, you’ll discover the beginning and the top have feedback as proven under:

# BEGIN WordPress

#HTACCESS Guidelines

# BEGIN WordPress

You must keep away from including any new directives inside these two strains of feedback since it might overwrite the prevailing guidelines.

12 Tips of Modifying WordPress htaccess

Earlier than you edit any htaccess, it’s all the time advisable you start by creating a backup copy. After the backup copy, you possibly can implement the next hacks in your htaccess.

thirteen The way to Prohibit Entry to WordPress wp-config.php

There’s all the time an eminent hazard of getting hacked in case you are operating a WordPress website. One of the simplest ways to safeguard your website from hackers is to tighten security in all of your WordPress installation information. Of specific curiosity is the wp-config.php file that shops the values of your database identify and the password. It connects your WordPress set up to the database. You’ll want to prohibit its entry utilizing the next code in your htaccess file:

#prohibit entry to wpconfig.php

<information wp-config.php>

order permit,deny

deny from all


14 Tips on how to Prohibit Entry to Your htaccess file

The second most necessary file that’s weak to take advantage of by hackers in your WordPress set up is the htaccess. WordPress htaccess file controls how the location behaves and if it isn’t protected new guidelines might be added that may have a damaging impression in your website. We have to shield the htaccess file utilizing the code under:

# prohibit entry to htaccess

<information ~ “^.*.([Hh][Tt][Aa])”>

order permit,deny

deny from all

fulfill all


15 The way to Cease WordPress Listing Shopping

Apache Net server permits individuals to entry information in your website by means of the browser; it’s worthwhile to shield your WordPress set up information by stopping individuals from listing searching. The entry of your WordPress uploads folder can lead you to lose your photographs and different content material in that folder and subsequently it’s crucial we cease the listing searching utilizing the next code in your htaccess:

Choices –Indexes

sixteen Methods to Cease Picture Hotlinking

Some individuals are probably to make use of your pictures by instantly hotlinking. There are a selection of the way to cease photographs getting hotlinked amongst them is a cPanel function to cease hotlinking. One other easy approach to cease it’s so as to add the next code in your WordPress htaccess file.

#Find out how to cease hotlinking in WordPress

RewriteEngine on

RewriteCond %HTTP_REFERER !^$

RewriteCond %HTTP_REFERER !^http(s)?://(www.)? [NC]

RewriteCond %HTTP_REFERER !^http(s)?://(www.)? [NC]

RewriteCond %HTTP_REFERER !^http(s)?://(www.)? [NC]

RewriteRule .(jpg|jpeg|png|gif)$ – [NC,F,L]

You have to edit and exchange the URL half together with your area earlier than it can save you the settings in your htaccess.

17 How you can Cease Entry to WordPress Admin

Permitting entry to your WordPress admin can result in your website getting weak. You have to cease entry to WordPress admin by modifying htaccess and creating an .htpasswds file that you need to place in your root WordPress set up. Typically it is best to place it within the public_html folder. It is best to now use the next code within the htaccess to limit entry to WordPress admin space by creating a further layer of safety.

AuthName “Joe Admin Solely allowed to login”

AuthUserFile C:xampphtdocs.htpasswd

AuthGroupFile /dev/null

AuthType primary

require consumer Njengah

<Information admin-ajax.php>

Order permit,deny

Permit from all

Fulfill any


For this illustration I used my native server, you need to exchange the authentication identify consumer and the trail together with your respective website’s values. When somebody tries to go to your WordPress admin web page, they are going to be prompted so as to add a username and password as proven within the picture under:

18 How one can Ban IPs and Bots from Your WordPress website

Top-of-the-line methods to cease spam feedback from bots is to dam the IPs. That is additionally helpful for blocking entry for individuals who attempt to hack your website. You’ll be able to edit htaccess and block customers based mostly on their IP. Including the next code to your htaccess blocks customers by IP:

#Banning WordPress website entry by IP

<Restrict GET POST>

order permit,deny

deny from

deny from
deny from

deny from

permit from all


It is best to exchange the XXXX with the respective IPs addresses that you simply need to ban from accessing your website.

19 The best way to Restrict WordPress File Uploads Measurement

Limiting the file add measurement is an important measure for membership websites. Members ought to solely add sure measurement information to save lots of your reminiscence and assist your website keep the loading velocity. You possibly can edit htaccess to restrict the dimensions of the add utilizing the next code in your htaccess:

# Restrict file uploads to 20MB LimitRequestBody 20240000

This limits the add sizes for information to twenty MB

20 How you can Optimize WordPress Website with GZip Compression

Saving your WordPress website bandwidth will definitely enhance your web page loading velocity. Page loading speed has develop into a rating indicator that Google makes use of to rank websites. GZip compression permits you to compress information and considerably enhance your web page load velocity. Luckily, you’ll be able to implement GZip compression by modifying the htaccess file. Right here is an instance of code you need to use in your htaccess file.

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE textual content/html textual content/plain textual content/xml textual content/css software/x-javascript
BrowserMatch ^Mozilla/four gzip-solely-textual content/html
BrowserMatch ^Mozilla/[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-solely-textual content/html

Additionally it is potential to do Gzip compression utilizing WordPress plugins obtainable however the htaccess GZip compression rids your website of pointless plugins.

21 The way to restrict WordPress login by IP Handle

Securing your WordPress website from hackers is an important measure when you will have a thriving WordPress website that’s incomes you some good revenue. The potential for having your WordPress website hacked is eminent particularly if in case you have not taken measures to cease hackers. One other approach of including a safety layer in your WordPress website is to stop different individuals from logging by limiting logins to sure IPs solely. This can be a foolproof approach of making certain that solely you and whitelisted individuals can login to your website.

# Restrict WordPress login admin by IP
# This goes within the /admin folder NOT root folder .htaccess
AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName “WordPress Admin Entry Management”
AuthType Primary
<Restrict GET POST PUT>
order deny,permit
deny from all
permit from xx.xx.xx.xx //( your static IP)
permit from xx.xx.xx.xx //( Whitelist IP)
permit from xx.xx.xx.xx //( Whitelist IP)
permit from xx.xx.xx.xx //( Whitelist IP)
permit from xx.xx.xx.xx //( Whitelist IP)
permit from xx.xx.xx.xx //( Whitelist IP)

It is best to substitute the XXX.XXX with the respective IPs that you’ve whitelisted. All different IPs might be blocked from accessing your WordPress logging and thereby safeguarding your website from hackers.

22 How you can Redirect Guests to Upkeep Web page in WordPress

In case you are sustaining sections of your website, you possibly can shortly redirect guests to you upkeep web page by modifying the htaccess file. Use the next code in your htaccess to create a redirect to your upkeep.html web page in your server.

RewriteEngine on

RewriteCond %REQUEST_URI !/upkeep.html$

RewriteCond %REMOTE_ADDR !^

RewriteRule $ /upkeep.html [R=302,L]

23 Methods to Create 301 Redirects for previous URLS in WordPress

Previous URLs which are damaged in your website could have a unfavorable impact in your rating. It’s advisable that each one the previous URLs are redirected to new URLs after altering the URLs construction. The simplest approach to redirect URLs is utilizing the htaccess; the next is an instance on how you can create URLs redirect utilizing htaccess:

Redirect 301 /oldurl/

Redirect 301 /class/well being/ http://www.yoursite/class/well being/

From the htaccess code above you’ll be able to see the primary redirects the previous URLs to the brand new one. The second line redirects the WordPress classes to the brand new class.

That is how one can entry and edit the htaccess file for performing totally different functionalities in your web site. Simply to ensure you don’t wind up in hassle, all the time hold the backup of your website and the htaccess file.

If discovered to edit appropriately, htaccess can be utilized for superior settings of your web site.

The best way to Edit the .htaccess File in WordPress? obtain the WordPress Theme

Obtain now The best way to Edit the .htaccess File in WordPress? theme.
Evaluation and opinions of How you can Edit the .htaccess File in WordPress? theme.

Rate it!
Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

How to Edit the .htaccess File in WordPress?
Voted 4.9/5 of 1 reviews.