{"id":839569,"date":"2018-10-30T12:09:39","date_gmt":"2018-10-30T11:09:39","guid":{"rendered":"https:\/\/wp-rocket.me\/?p=839569"},"modified":"2021-07-29T10:08:06","modified_gmt":"2021-07-29T08:08:06","slug":"htaccess-use-wordpress","status":"publish","type":"post","link":"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/","title":{"rendered":"What is .htaccess and How to Use it With WordPress"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">WordPress relies on several core files to run your website and the powerful .htaccess configuration file is one of them.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Short for \u201chypertext access,\u201d WordPress uses this file primarily to handle pretty permalinks. But its true power lies in its ability to override your server\u2019s settings\u2014enabling you to add your own rules to this file that can beef up your site\u2019s performance and security.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Some of this additional functionality includes locking outside access to critical files, sending custom HTTP heads, forcing SSL, and restricting access to the WordPress dashboard.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In this post, we\u2019ll take a look at how .htaccess works and how to edit it. Plus, we\u2019ll look at some examples of what you can do with this file to improve your site\u2019s performance.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-839583 size-full\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-panel-rules.png\" alt=\"htaccess panel rules preview\" width=\"601\" height=\"421\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-panel-rules.png 601w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-panel-rules-300x210.png 300w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/p>\n<h2><span style=\"font-weight: 400;\">What is the .htaccess File?<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">The .htaccess file is a configuration file that WordPress uses for Apache web servers. Since most WordPress web hosts use Apache, most WordPress websites also have a .htaccess file.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This file is usually located in the root directory of your site. But since it sets out how Apache should handle configuration for your site on a per-directory basis, you might also find versions of this file in other folders on your site.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It\u2019s a hidden file\u2014that\u2019s why it starts with a period\u2014and it has no extension. This means you won\u2019t be able to see it when browsing your files unless you show all hidden files on your computer.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In WordPress, .htaccess has one important function: it controls how your site\u2019s permalinks are displayed. The file is automatically generated the first time you customize your permalinks, and if you make any subsequent changes to your permalink structure the file is automatically updated with new rules.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For many small and basic WordPress sites, handling permalinks is all the .htaccess will ever do. But for more larger and more complex sites, .htaccess is often manipulated by plugins. This is especially common for security and caching plugins like WP Rocket, which\u00a0<\/span><a href=\"https:\/\/docs.wp-rocket.me\/article\/63-enable-gzip-compression\"><span style=\"font-weight: 400;\">edits .htaccess to enable GZIP compression for your site<\/span><\/a><span style=\"font-weight: 400;\"> and adds the optimal browser caching rules.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It\u2019s also possible to make your own changes to .htaccess to enable\/disable advanced functionality on your site. In fact, there\u2019s a lot you can do, such as prevent directory browsing, restrict access to PHP files, and even protect your site against script injections.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">How to Find the .htaccess File in WordPress<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">The .htaccess file is located in the root directory of your site. But before you go hunting around for it and making changes, it\u2019s important to understand that editing this file comes with risks\u2014a single syntax error could mess with key functionality, or even break your site.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">Getting Started: Create a Backup<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">So make sure you back up your site before editing this file. Alternatively, you could use a staging site to update .htaccess and test changes to your site\u2019s functionality before pushing them live.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you prefer to fly by the seat of your pants and edit your site live, it\u2019s a good idea to download a copy of your .htaccess file to your computer so you at least have a backup. This way, if you do break your site, you can simply upload the original copy of the file to your server and pretend like nothing happened.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">There are typically three ways you can access your .htaccess file:<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">1. Editing .htaccess Using cPanel<\/span><\/h3>\n<ol>\n<li><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Log into cPanel for your site and go to \u201cFile Manager.\u201d<\/span><\/span><\/span><\/span><\/li>\n<li><span style=\"font-weight: 400;\">File Manager will load and display a list of files on your web server. Look for \u201c<\/span><i><span style=\"font-weight: 400;\">public_html<\/span><\/i><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u201d and click on that.<\/span><\/span><\/span><\/span><\/li>\n<li><span style=\"font-weight: 400;\">You are now in the root directory for your website (unless you set up your site in a sub-directory). Scroll through your files and look for the .htaccess file:<\/span><\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-839596 size-full\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-file-cpanel.png\" alt=\"how to find htaccess in cpanel\" width=\"635\" height=\"457\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-file-cpanel.png 635w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-file-cpanel-300x216.png 300w\" sizes=\"(max-width: 635px) 100vw, 635px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">If you can\u2019t see the file, you\u2019ve either not got one or you need to change your settings for hidden files.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To update hidden files settings, click on \u201cSettings\u201d in the top-right corner of File Manager and in the modal that appears check \u201cShow Hidden Files.\u201d<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-839608 size-full\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-file-hidden.png\" alt=\"update hidden files settings\" width=\"521\" height=\"361\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-file-hidden.png 521w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-file-hidden-300x208.png 300w\" sizes=\"(max-width: 521px) 100vw, 521px\" \/><\/p>\n<h3><span style=\"font-weight: 400;\">2. Editing .htaccess Using FTP<\/span><\/h3>\n<p><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">1. Grab your FTP details and log in to your site using your favorite FTP app (I\u2019m using FileZilla).<\/span><\/span><\/span><\/span><\/p>\n<p><span style=\"font-weight: 400;\">2. Once your FTP client is connected to your site, you should see your server\u2019s root files in the bottom-right quadrant, like so:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-839616 size-full\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/server-root-files-ftp.png\" alt=\"how to edit htaccess file via FTP\" width=\"800\" height=\"392\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/server-root-files-ftp.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/server-root-files-ftp-300x147.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/server-root-files-ftp-768x376.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">3. Scroll through the list of files until you find \u201c<\/span><i><span style=\"font-weight: 400;\">public_html<\/span><\/i><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u201d and then double-click it.<\/span><\/span><\/span><\/span><\/p>\n<p><span style=\"font-weight: 400;\">4. You\u2019ll now be in your site\u2019s root directory (unless, of course, you set up WordPress in a sub-directory). Scroll through the files listed and you should see your .htaccess file:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-839622 size-full\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-file-in-root-directory.png\" alt=\"htaccess file in root directory\" width=\"565\" height=\"216\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-file-in-root-directory.png 565w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-file-in-root-directory-300x115.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-file-in-root-directory-460x175.png 460w\" sizes=\"(max-width: 565px) 100vw, 565px\" \/><\/p>\n<h3><span style=\"font-weight: 400;\">3. Editing .htaccess Using a Plugin<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">There are many free plugins that can enable you to edit the .htaccess file, but one of the most popular is Yoast SEO.<br \/><\/span><span style=\"font-weight: 400;\">To access your .htaccess file in the WordPress dashboard:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">1. Log in to your site and navigate to <\/span><b>SEO &gt; General<\/b><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">.<\/span><\/span><\/span><\/span><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">2. In the tab at the top of the page, click on \u201cFeatures\u201d and then scroll down to &#8220;Security: no advanced settings for authors\u201d and turn this option off. Save your changes.<\/span><\/span><\/span><\/span><\/p>\n<p><span style=\"font-weight: 400;\">3. Next, go to <\/span><b>SEO &gt; Tools<\/b><span style=\"font-weight: 400;\"> and you should see a \u201cFile editor\u201d option. This tool allows you to make changes to your .htaccess file.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Note: If file editing is disabled on your site, as it is on mine (hence the lack of imagery here), then you won\u2019t see this option in your WordPress install. You\u2019ll need to use another method for accessing your .htaccess file.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Creating a <\/span><i><span style=\"font-weight: 400;\">.htaccess<\/span><\/i><span style=\"font-weight: 400;\"> File If You Don\u2019t Already Have One<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">If you don\u2019t have a .htaccess file in your root directory you may need to create one. But first, double-check that you definitely have hidden files showing so you don\u2019t inadvertently create a second copy (and replace your original file by accident).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The easiest way to create one is to simply go to <\/span><b>Settings &gt; Permalinks<\/b><span style=\"font-weight: 400;\"> in the WordPress dashboard and click \u201cSave Changes.\u201d WordPress will automatically generate a file, and you don\u2019t actually have to switch to different permalink settings.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Alternatively, if you want to create and edit and contents of your file, here\u2019s how to create one using cPanel:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">1. In File Manager, go to your root directory (<\/span><i><span style=\"font-weight: 400;\">public_html<\/span><\/i><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">).<\/span><\/span><\/span><\/span><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">2. Click \u201cFile\u201d in the top-left and enter .htaccess. Click \u201cCreate New File\u201d:<\/span><\/span><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-839628 size-full\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/create-new-htaccess-file.png\" alt=\"how to create a new htaccess file\" width=\"514\" height=\"265\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/create-new-htaccess-file.png 514w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/create-new-htaccess-file-300x155.png 300w\" sizes=\"(max-width: 514px) 100vw, 514px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">3. The root directory will refresh and you should see your newly created .htaccess file listed amongst your files.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Since all WordPress installs have pretty permalinks turned on by default (since WordPress 4.2), it\u2019s a good idea to include the basic rules that are default for .htaccess files in newer versions of WordPress rather than having an empty file.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">So you\u2019ll need to edit your blank .htaccess file to enter these rules.<br \/><\/span><span style=\"font-weight: 400;\">While still in your root directory, make sure .htaccess is selected and click the \u201cEdit\u201d option at the top of the page:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-839636 size-full\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/how-to-edit-htaccess-file.png\" alt=\"how to add rules on a new htaccess file\" width=\"731\" height=\"388\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/how-to-edit-htaccess-file.png 731w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/how-to-edit-htaccess-file-300x159.png 300w\" sizes=\"(max-width: 731px) 100vw, 731px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">A new tab will open where you can add the following configuration rules:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-839641 size-full\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-file-edit-settings.png\" alt=\"how to add configuration rules on htaccess\" width=\"649\" height=\"307\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-file-edit-settings.png 649w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/htaccess-file-edit-settings-300x142.png 300w\" sizes=\"(max-width: 649px) 100vw, 649px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">For Multisite networks and other versions of WordPress, you\u2019ll need to enter different rules. You can find the full list of<\/span><a href=\"https:\/\/codex.wordpress.org\/htaccess\" target=\"_blank\" rel=\"noopener noreferrer\"> <span style=\"font-weight: 400;\">default .htaccess file rules in the WordPress Codex<\/span><\/a><span style=\"font-weight: 400;\">. <\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Editing the .htaccess File <\/span><\/h2>\n<p><span style=\"font-weight: 400;\">There are a few important things to know when making changes to the .htaccess file.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Firstly, lines that begin with a hashtag are comments, not actual rules. So these lines don\u2019t really do anything other than provide handy markers amongst the text to tell you where rules start and end.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Secondly, when adding new rules you should insert them either above or below the default WordPress rules. You shouldn\u2019t add or edit anything between the lines that start with <\/span><span style=\"font-weight: 400;\"><code># BEGIN WordPress<\/code><\/span><span style=\"font-weight: 400;\"> and <\/span><span style=\"font-weight: 400;\"><code># END WordPress<\/code><\/span><span style=\"font-weight: 400;\">. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Generally, the norm is to add any new rules below the default WordPress instructions. This way, you\u2019ll always know that the WordPress rules are at the top of the file and any new rules are listed out below.<br \/>Nevertheless, <strong>WP Rocket represents an exception in this sense<\/strong>: its rules need to be placed right at the top of the .htaccess file; <a href=\"https:\/\/wp-rocket.me\/features\/\">the plugin will automatically add them<\/a>, so you don&#8217;t need to edit anything in this case.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You might also want to consider adding in your own comments, especially if you add lots of new rules around security and performance to your file as it could quickly get messy. Comments can help you quickly find rules, track what\u2019s changed, and keep your file organized.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">When adding new rules to .htaccess, it\u2019s a good idea to save your changes and refresh your site to check that your site is still functioning properly. This will also tell if any particular rules break your site, and if they do you can simply remove the troublesome rule or upload a backup of your .htaccess to get your site working properly again.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Examples of .htaccess Rules for WordPress<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Adding new rules to your .htaccess file lets you take back more control over your site and server and make changes that boost your site performance.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Before we dive in, though, make sure you duplicate your .htaccess file so you\u2019ve got a backup. You may find that your web host doesn\u2019t support some of the rules or you may inadvertently make a typo and break your site.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Whatever the case may be, the easiest thing is to simply make a copy of .htaccess and rename it something like<\/span><i><span style=\"font-weight: 400;\"> .htaccess_original<\/span><\/i><span style=\"font-weight: 400;\">. This way, when you\u2019re making changes to your file and discover that you need to roll back, all you need to do is rename the file and upload it to your root directory.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">Enable HTTP Compression<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">All modern browsers support and automatically negotiate GZIP compression for all HTTP requests. Enabling GZIP,<\/span> <a href=\"https:\/\/wp-rocket.me\/blog\/gzip-compression-wordpress\/\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">as I wrote about on this blog a couple of weeks back<\/span><\/a><span style=\"font-weight: 400;\">, can often achieve compression rates as high as 70-90%. This can significantly reduce the amount of time it takes to download resources, reduce data usage for site visitors, and improve the time to first render of your pages.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Now, it\u2019s important to point out here that WP Rocket adds GZIP compression rules to your .htaccess file automatically using the mod_deflate module. So if you\u2019re using WP Rocket, you don\u2019t have to do anything\u2014GZIP is already enabled and working on your site.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">But to give you an idea of what the <\/span><span style=\"font-weight: 400;\">mod_deflate<\/span><span style=\"font-weight: 400;\"> module looks like, here\u2019s a simplified version:<br \/><\/span><br \/><code><span style=\"font-weight: 400;\">&lt;ifmodule mod_deflate.c&gt;<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">AddOutputFilterByType DEFLATE <\/span><span style=\"font-weight: 400;\">text<\/span><span style=\"font-weight: 400;\">\/html <\/span><span style=\"font-weight: 400;\">text<\/span><span style=\"font-weight: 400;\">\/plain <\/span><span style=\"font-weight: 400;\">text<\/span><span style=\"font-weight: 400;\">\/xml <\/span><span style=\"font-weight: 400;\">application<\/span><span style=\"font-weight: 400;\">\/xml <\/span><span style=\"font-weight: 400;\">application<\/span><span style=\"font-weight: 400;\">\/xhtml+xml <\/span><span style=\"font-weight: 400;\">text<\/span><span style=\"font-weight: 400;\">\/javascript <\/span><span style=\"font-weight: 400;\">text<\/span><span style=\"font-weight: 400;\">\/css <\/span><span style=\"font-weight: 400;\">application<\/span><span style=\"font-weight: 400;\">\/x-javascript <\/span><span style=\"font-weight: 400;\">application<\/span><span style=\"font-weight: 400;\">\/javascript<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">&lt;\/ifmodule&gt;<\/span><\/code><\/p>\n<h3>Prevent Image Hotlinking<\/h3>\n<p><span style=\"font-weight: 400;\">Every image on your pages sends a separate HTTP request to your server. So when someone uses the URL for one of your images and adds it to their site instead of uploading the image to their server, they\u2019re stealing your bandwidth.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This technique is known as hotlinking. To stop this happening to your site, add the following to your .htaccess file:<\/span><br \/><code><br \/>\n<b>RewriteEngine<\/b> <span style=\"font-weight: 400;\">on<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><b>RewriteCond<\/b> <span style=\"font-weight: 400;\">%{HTTP_REFERER}<\/span><span style=\"font-weight: 400;\"> !^$<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><b>RewriteCond<\/b> <span style=\"font-weight: 400;\">%{HTTP_REFERER}<\/span><span style=\"font-weight: 400;\"> !^http:\/\/(www\\.)?yourdomain.com\/.*$<\/span><span style=\"font-weight: 400;\"> [NC]<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><b>RewriteRule<\/b><span style=\"font-weight: 400;\"> \\.(gif|jpg|png)$ -<\/span><span style=\"font-weight: 400;\"> [F]<\/span><\/code><\/p>\n<p>Make sure you replace \u201cyourdomain.com\u201d with your site\u2019s URL.<\/p>\n<p><span style=\"font-weight: 400;\">For more examples of .htaccess rules to help you boost your site\u2019s performance and security, check out the\u00a0<\/span><a href=\"https:\/\/codex.wordpress.org\/htaccess\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">htaccess entry in the WordPress Codex<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<div id=\"om-ulrdquoprwqcywqbbgci-holder\"><\/div>\n\t<script>(function (d, u, ac) {\n\t\t\tvar s = d.createElement('script')\n\t\t\ts.type = 'text\/javascript'\n\t\t\ts.src = 'https:\/\/a.omappapi.com\/app\/js\/api.min.js'\n\t\t\ts.async = true\n\t\t\ts.dataset.user = u\n\t\t\ts.dataset.campaign = ac\n\t\t\td.getElementsByTagName('head')[0].appendChild(s)\n\t\t})(document, 20440, 'ulrdquoprwqcywqbbgci')<\/script>\n<h2><span style=\"font-weight: 400;\">Conclusion<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Learning how to work with and edit your site\u2019s .htaccess file can help you make powerful changes to your site\u2019s server configuration, enabling you to improve your site\u2019s performance and security. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">You can find more examples of rules you can add to your .htaccess file in the\u00a0<\/span><a href=\"https:\/\/codex.wordpress.org\/htaccess\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">WordPress Codex<\/span><\/a><span style=\"font-weight: 400;\">. There are also plenty of developer blogs and <\/span><a href=\"https:\/\/webmasters.stackexchange.com\/questions\/tagged\/htaccess\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">threads at StackExchange<\/span><\/a><span style=\"font-weight: 400;\"> featuring tips and tricks for editing .htaccess.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Lastly, don\u2019t forget to back up your site whenever you make changes to core WordPress files like .htaccess so you can quickly and easily restore your site if anything goes wrong.<\/span><\/p>\n<p><i><span style=\"font-weight: 400;\">Have you edited your .htaccess? Share your questions or tips for using .htaccess rules in the comments below.<\/span><\/i><\/p><p><\/p>","protected":false},"excerpt":{"rendered":"<p>WordPress relies on several core files to run your website and the powerful .htaccess configuration file is one of them. Short for \u201chypertext access,\u201d WordPress uses this file primarily to handle pretty permalinks. But its true power lies in its ability to override your server\u2019s settings\u2014enabling you to add your own rules to this file [&hellip;]<\/p>\n","protected":false},"author":47285,"featured_media":839703,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"kia_subtitle":"","footnotes":""},"categories":[61],"tags":[],"class_list":["post-839569","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-seo"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is .htaccess and How to Use it With WordPress<\/title>\n<meta name=\"description\" content=\"The .htaccess file in your WordPress install is a powerful config file. Learn how to use it to override server settings to improve your site\u2019s performance.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is .htaccess and How to Use it With WordPress\" \/>\n<meta property=\"og:description\" content=\"The .htaccess file in your WordPress install is a powerful config file. Learn how to use it to override server settings to improve your site\u2019s performance.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"WP Rocket\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-30T11:09:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-29T08:08:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/what-is-htaccess-file.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"460\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Raelene Morey\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@wp_rocket\" \/>\n<meta name=\"twitter:site\" content=\"@wp_rocket\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Raelene Morey\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/\"},\"author\":{\"name\":\"Raelene Morey\",\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/person\/916d553a975868ce90654f343fa25d73\"},\"headline\":\"What is .htaccess and How to Use it With WordPress\",\"datePublished\":\"2018-10-30T11:09:39+00:00\",\"dateModified\":\"2021-07-29T08:08:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/\"},\"wordCount\":1980,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/wp-rocket.me\/#organization\"},\"image\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/what-is-htaccess-file.png\",\"articleSection\":[\"SEO\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/\",\"url\":\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/\",\"name\":\"What is .htaccess and How to Use it With WordPress\",\"isPartOf\":{\"@id\":\"https:\/\/wp-rocket.me\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/what-is-htaccess-file.png\",\"datePublished\":\"2018-10-30T11:09:39+00:00\",\"dateModified\":\"2021-07-29T08:08:06+00:00\",\"description\":\"The .htaccess file in your WordPress install is a powerful config file. Learn how to use it to override server settings to improve your site\u2019s performance.\",\"breadcrumb\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#primaryimage\",\"url\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/what-is-htaccess-file.png\",\"contentUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/what-is-htaccess-file.png\",\"width\":1100,\"height\":460,\"caption\":\"what is htaccess file and how to use it on wordpress\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/wp-rocket.me\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SEO\",\"item\":\"https:\/\/wp-rocket.me\/blog\/seo\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"What is .htaccess and How to Use it With WordPress\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/wp-rocket.me\/#website\",\"url\":\"https:\/\/wp-rocket.me\/\",\"name\":\"WP Rocket\",\"description\":\"Plugin d&#039;optimisation de sites WordPress\",\"publisher\":{\"@id\":\"https:\/\/wp-rocket.me\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/wp-rocket.me\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/wp-rocket.me\/#organization\",\"name\":\"WP Rocket\",\"url\":\"https:\/\/wp-rocket.me\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png\",\"contentUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png\",\"width\":150,\"height\":41,\"caption\":\"WP Rocket\"},\"image\":{\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829\",\"https:\/\/x.com\/wp_rocket\",\"https:\/\/www.youtube.com\/channel\/UC1ozThXHd1IWIZ5wkshgp_Q\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/person\/916d553a975868ce90654f343fa25d73\",\"name\":\"Raelene Morey\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fa33964c6065acf9d0348d177213ec83?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/fa33964c6065acf9d0348d177213ec83?s=96&d=mm&r=g\",\"caption\":\"Raelene Morey\"},\"description\":\"Raelene Morey is the Co-Founder of Words By Birds, a digital writing agency that helps busy WordPress with writing articles, content strategies, lead magnets and other word-related things. A former journalist and editor, Raelene has been developing WordPress sites for over 10 years.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is .htaccess and How to Use it With WordPress","description":"The .htaccess file in your WordPress install is a powerful config file. Learn how to use it to override server settings to improve your site\u2019s performance.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/","og_locale":"en_US","og_type":"article","og_title":"What is .htaccess and How to Use it With WordPress","og_description":"The .htaccess file in your WordPress install is a powerful config file. Learn how to use it to override server settings to improve your site\u2019s performance.","og_url":"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/","og_site_name":"WP Rocket","article_publisher":"https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829","article_published_time":"2018-10-30T11:09:39+00:00","article_modified_time":"2021-07-29T08:08:06+00:00","og_image":[{"width":1100,"height":460,"url":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/what-is-htaccess-file.png","type":"image\/png"}],"author":"Raelene Morey","twitter_card":"summary_large_image","twitter_creator":"@wp_rocket","twitter_site":"@wp_rocket","twitter_misc":{"Written by":"Raelene Morey","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#article","isPartOf":{"@id":"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/"},"author":{"name":"Raelene Morey","@id":"https:\/\/wp-rocket.me\/#\/schema\/person\/916d553a975868ce90654f343fa25d73"},"headline":"What is .htaccess and How to Use it With WordPress","datePublished":"2018-10-30T11:09:39+00:00","dateModified":"2021-07-29T08:08:06+00:00","mainEntityOfPage":{"@id":"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/"},"wordCount":1980,"commentCount":1,"publisher":{"@id":"https:\/\/wp-rocket.me\/#organization"},"image":{"@id":"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/what-is-htaccess-file.png","articleSection":["SEO"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/","url":"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/","name":"What is .htaccess and How to Use it With WordPress","isPartOf":{"@id":"https:\/\/wp-rocket.me\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#primaryimage"},"image":{"@id":"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/what-is-htaccess-file.png","datePublished":"2018-10-30T11:09:39+00:00","dateModified":"2021-07-29T08:08:06+00:00","description":"The .htaccess file in your WordPress install is a powerful config file. Learn how to use it to override server settings to improve your site\u2019s performance.","breadcrumb":{"@id":"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#primaryimage","url":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/what-is-htaccess-file.png","contentUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/what-is-htaccess-file.png","width":1100,"height":460,"caption":"what is htaccess file and how to use it on wordpress"},{"@type":"BreadcrumbList","@id":"https:\/\/wp-rocket.me\/blog\/htaccess-use-wordpress\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wp-rocket.me"},{"@type":"ListItem","position":2,"name":"SEO","item":"https:\/\/wp-rocket.me\/blog\/seo\/"},{"@type":"ListItem","position":3,"name":"What is .htaccess and How to Use it With WordPress"}]},{"@type":"WebSite","@id":"https:\/\/wp-rocket.me\/#website","url":"https:\/\/wp-rocket.me\/","name":"WP Rocket","description":"Plugin d&#039;optimisation de sites WordPress","publisher":{"@id":"https:\/\/wp-rocket.me\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wp-rocket.me\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/wp-rocket.me\/#organization","name":"WP Rocket","url":"https:\/\/wp-rocket.me\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/","url":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png","contentUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png","width":150,"height":41,"caption":"WP Rocket"},"image":{"@id":"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829","https:\/\/x.com\/wp_rocket","https:\/\/www.youtube.com\/channel\/UC1ozThXHd1IWIZ5wkshgp_Q"]},{"@type":"Person","@id":"https:\/\/wp-rocket.me\/#\/schema\/person\/916d553a975868ce90654f343fa25d73","name":"Raelene Morey","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wp-rocket.me\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/fa33964c6065acf9d0348d177213ec83?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fa33964c6065acf9d0348d177213ec83?s=96&d=mm&r=g","caption":"Raelene Morey"},"description":"Raelene Morey is the Co-Founder of Words By Birds, a digital writing agency that helps busy WordPress with writing articles, content strategies, lead magnets and other word-related things. A former journalist and editor, Raelene has been developing WordPress sites for over 10 years."}]}},"_links":{"self":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/posts\/839569"}],"collection":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/users\/47285"}],"replies":[{"embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/comments?post=839569"}],"version-history":[{"count":0,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/posts\/839569\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/media\/839703"}],"wp:attachment":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/media?parent=839569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/categories?post=839569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/tags?post=839569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}