{"id":756,"date":"2021-04-18T21:21:00","date_gmt":"2021-04-18T19:21:00","guid":{"rendered":"https:\/\/blog.pirulug.com\/?p=756"},"modified":"2026-07-14T17:41:46","modified_gmt":"2026-07-14T15:41:46","slug":"howtos-making-sure-htaccess-and-mod_rewrite-are-working-as-they-should","status":"publish","type":"post","link":"https:\/\/blog.pirulug.com\/?p=756","title":{"rendered":"HOWTOs \/ Making sure .htaccess and mod_rewrite are working as they should"},"content":{"rendered":"<p>JUMP TO:<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.bolt.cm\/4.0\/howto\/making-sure-htaccess-works#test-if-htaccess-is-working\">Test if .htaccess is working<\/a><\/li>\n<li><a href=\"https:\/\/docs.bolt.cm\/4.0\/howto\/making-sure-htaccess-works#test-if-mod-rewrite-is-working\">Test if mod_rewrite is working<\/a><\/li>\n<li><a href=\"https:\/\/docs.bolt.cm\/4.0\/howto\/making-sure-htaccess-works#my-htaccess-is-broken-what-do\">My htaccess is broken? What do?<\/a><\/li>\n<\/ul>\n<p>Bolt makes extensive use of a common feature called \u2018url rewriting\u2019. This basically means that you can request a pretty url like  <code>\/page\/about-this-website<\/code>  in your browser, and behind the scenes your web server will just \u2018translate\u2019 this to run the  <code>index.php<\/code>  with the correct parameters, so that Bolt can produce the correct page for you.<\/p>\n<p>This doesn\u2019t work out-of-the-box on all web servers, but it  <em>is<\/em>  a hard requirement for using Bolt. If you\u2019re reading this page, you are likely in the process of setting up Bolt and after requesting the first page, you got redirected to the page  <code>\/bolt\/userfirst<\/code>, where you saw the following error message:<\/p>\n<p><a href=\"https:\/\/blog.pirulug.com\/wp-content\/uploads\/2021\/04\/htaccess-4.webp\" title=\"bolt\/userfirst not found\"><img decoding=\"async\" src=\"https:\/\/blog.pirulug.com\/wp-content\/uploads\/2021\/04\/htaccess-4.webp\" alt=\"\"><\/a><\/p>\n<p>One of the three following possibilities is giving you problems:<\/p>\n<ul>\n<li>You\u2019ve misplaced the .htaccess file<\/li>\n<li>Apache ignores  <code>.htaccess<\/code>  altogether<\/li>\n<li>Mod_rewrite is not enabled<\/li>\n<\/ul>\n<h2 id=\"test-if--.htaccess--is-working\u00b6\">Test if  <code>.htaccess<\/code>  is working<a href=\"https:\/\/docs.bolt.cm\/4.0\/howto\/making-sure-htaccess-works#test-if-htaccess-is-working\">\u00b6<\/a><\/h2>\n<p>The simplest way to test if apache uses your  <code>.htaccess<\/code>  file, or if it otherwise ignores it, is to intentionally break it.<\/p>\n<p>Edit the  <code>.htaccess<\/code>  file, so the first line reads \u2018Test.\u2019:<\/p>\n<pre class=\" language-apache\"><code class=\"prism  language-apache\">Test.\n\n# Set the default handler\nDirectoryIndex index.php index.html index.htm\n\n...\n\n<\/code><\/pre>\n<p>Now, if you refresh the page in your browser, you should see an error page like this:<\/p>\n<p><a href=\"https:\/\/blog.pirulug.com\/wp-content\/uploads\/2021\/04\/htaccess-2.webp\" title=\"Htaccess working\"><img decoding=\"async\" src=\"https:\/\/blog.pirulug.com\/wp-content\/uploads\/2021\/04\/htaccess-2.webp\" alt=\"\"><\/a><\/p>\n<p>If you see this error, that\u2019s  <strong>actually good<\/strong>! This means that Apache is parsing the  <code>.htaccess<\/code>  file, and it encounters the error we\u2019ve put in there! So far, so good!<\/p>\n<p>If you do  <em>not<\/em>  see an \u2018Internal Server Error\u2019, your Apache setup ignores the  <code>.htaccess<\/code>  file, and you need to fix that. Generally, Apache ignores the  <code>.htaccess<\/code>  file because of the following Apache configuration  <code>AllowOverride none<\/code>. Check your virtual host configuration and add\/amend to  <code>AllowOverride All<\/code>.<\/p>\n<p>Example:<\/p>\n<pre class=\" language-apache\"><code class=\"prism  language-apache\">    &lt;Directory \/var\/www\/site\/example.com\/&gt;\n        Options Indexes FollowSymLinks\n        AllowOverride All\n        Require all granted\n    &lt;\/Directory&gt;\n<\/code><\/pre>\n<p>If you are not sure if the  <code>.htaccess<\/code>  file exists and is readable, download our test script:<\/p>\n<ul>\n<li>Download the script here:  <a href=\"https:\/\/raw.githubusercontent.com\/bolt\/htaccess_tester\/master\/htaccess_tester.php\">htaccess_tester.php on GitHub<\/a><\/li>\n<li>Rename it to  <code>htaccess_tester.php<\/code>, if needed.<\/li>\n<li>Place it in the folder where you\u2019ve put Bolt.<\/li>\n<li>Open it in the browser with the URL. (so, make sure you\u2019re not accessing it as a  <code>file:\/\/<\/code>)<\/li>\n<li>If you get an error, you will need to fix it by making sure the  <code>.htaccess<\/code>  file exists and is readable.<\/li>\n<\/ul>\n<p>This is correct:<\/p>\n<p><a href=\"https:\/\/blog.pirulug.com\/wp-content\/uploads\/2021\/04\/htaccess-3.webp\" title=\"Htaccess working\"><img decoding=\"async\" src=\"https:\/\/blog.pirulug.com\/wp-content\/uploads\/2021\/04\/htaccess-3.webp\" alt=\"\"><\/a><\/p>\n<h2 id=\"test-if--mod_rewrite--is-working\u00b6\">Test if  <code>mod_rewrite<\/code>  is working<a href=\"https:\/\/docs.bolt.cm\/4.0\/howto\/making-sure-htaccess-works#test-if-mod-rewrite-is-working\">\u00b6<\/a><\/h2>\n<p>To test if  <code>mod_rewrite<\/code>  is working correctly, do the following:<\/p>\n<ul>\n<li>Download the script here:  <a href=\"https:\/\/raw.githubusercontent.com\/bolt\/htaccess_tester\/master\/htaccess_tester.php\">htaccess_tester.php on GitHub<\/a><\/li>\n<li>Rename it to  <code>htaccess_tester.php<\/code>, if needed.<\/li>\n<li>Place it in the folder where you\u2019ve put Bolt.<\/li>\n<li>Create a  <code>.htaccess<\/code>  file with the contents as below.<\/li>\n<\/ul>\n<pre class=\" language-apache\"><code class=\"prism  language-apache\">&lt;IfModule mod_rewrite.c&gt;\n    RewriteEngine On\n    RewriteRule ^.*$ htaccess_tester.php\n&lt;\/IfModule&gt;\n<\/code><\/pre>\n<ul>\n<li>In your browser, open  <code>\/test<\/code>, with the correct domain name. So, it should look like  <code>http:\/\/localhost\/test<\/code>  or  <code>http:\/\/example.org\/test<\/code>.<\/li>\n<li>If you see the following, it works! If you see something else, you will need to fix that.<\/li>\n<\/ul>\n<p>This is correct:<\/p>\n<p><a href=\"https:\/\/blog.pirulug.com\/wp-content\/uploads\/2021\/04\/htaccess-1.webp\" title=\"Htaccess working\"><img decoding=\"async\" src=\"https:\/\/blog.pirulug.com\/wp-content\/uploads\/2021\/04\/htaccess-1.webp\" alt=\"\"><\/a><\/p>\n<h2 id=\"my-htaccess-is-broken-what-do\u00b6\">My htaccess is broken? What do?<a href=\"https:\/\/docs.bolt.cm\/4.0\/howto\/making-sure-htaccess-works#my-htaccess-is-broken-what-do\">\u00b6<\/a><\/h2>\n<p>There are a plethora of reasons why it might not work on your system, and these reasons vary so wildly, that we can\u2019t give an exhaustive solution for that. That said, here are a few pointers that might help you fix it:<\/p>\n<h3 id=\"enable--.htaccess--in-your--httpd.conf--or--apache.conf\u00b6\">Enable  <code>.htaccess<\/code>  in your  <code>httpd.conf<\/code>  or  <code>apache.conf<\/code><a href=\"https:\/\/docs.bolt.cm\/4.0\/howto\/making-sure-htaccess-works#enable-htaccess-in-your-httpd-conf-or-apache-conf\">\u00b6<\/a><\/h3>\n<p>It\u2019s unusual, but possible that  <code>.htaccess<\/code>  is not enabled on your site. If you are hosting it yourself, it\u2019s easy enough to fix. Open your  <code>httpd.conf<\/code>  or  <code>apache.conf<\/code>  in a text editor, and locate the  <code>&lt;Directory&gt;<\/code>  section:<\/p>\n<pre class=\" language-apache\"><code class=\"prism  language-apache\">&lt;Directory &quot;\/var\/www\/htdocs&quot;&gt;\n    AllowOverride None\n<\/code><\/pre>\n<p>Change the  <code>AllowOverride<\/code>  line to:<\/p>\n<pre class=\" language-apache\"><code class=\"prism  language-apache\">    AllowOverride All\n<\/code><\/pre>\n<p>Be sure to restart Apache after making any modifications to this file. Now, your  <code>.htaccess<\/code>  should work. You can also make this change inside a virtual host, which would normally be preferable, but that depends on the way Apache is set up.<\/p>\n<p>If your site is hosted elsewhere, check your control panel (Plesk, DirectAdmin, CPanel, whatever) to see if you can enable  <code>.htaccess<\/code>  there. If not, contact your hosting provider to do it for you.<\/p>\n<h3 id=\"enable--mod_rewrite--in-apache\u00b6\">Enable  <code>mod_rewrite<\/code>  in Apache<a href=\"https:\/\/docs.bolt.cm\/4.0\/howto\/making-sure-htaccess-works#enable-mod-rewrite-in-apache\">\u00b6<\/a><\/h3>\n<p>There are a number of ways to enable  <code>mod_rewrite<\/code>, in case it\u2019s not yet enabled on your setup. See this Stack Overflow thread for various ways this may be done on different setups:  <a href=\"http:\/\/stackoverflow.com\/questions\/869092\/how-to-enable-mod-rewrite-for-apache-2-2\">How to enable mod_rewrite for Apache 2.2<\/a>.<\/p>\n<h3 id=\"inspect-apaches-logfiles\u00b6\">Inspect Apache\u2019s logfiles<a href=\"https:\/\/docs.bolt.cm\/4.0\/howto\/making-sure-htaccess-works#inspect-apache-s-logfiles\">\u00b6<\/a><\/h3>\n<p>Apache logs a  <em>lot<\/em>  of stuff. Inspect the \u2018access\u2019 and \u2018error\u2019 logs generated by Apache to see if they contain valuable information. A common location for these files is  <code>\/var\/log\/apache2\/<\/code>, but it might be in a different path on your system. Check your apache  <code>.conf<\/code>  file to see where these files might be hiding.<\/p>\n<h3 id=\"enabling-rewritebase\u00b6\">Enabling Rewritebase<a href=\"https:\/\/docs.bolt.cm\/4.0\/howto\/making-sure-htaccess-works#enabling-rewritebase\">\u00b6<\/a><\/h3>\n<p>If you\u2019re setting up Bolt in a subfolder, you might have to uncomment the line for the  <code>RewriteBase<\/code>  setting.<\/p>\n<p>Change<\/p>\n<pre class=\" language-apache\"><code class=\"prism  language-apache\">  # Some servers require the RewriteBase to be set. If so, set to the correct folder.\n  # RewriteBase \/\n<\/code><\/pre>\n<p>to:<\/p>\n<pre class=\" language-apache\"><code class=\"prism  language-apache\">  # Some servers require the RewriteBase to be set. If so, set to the correct folder.\n  RewriteBase \/\n<\/code><\/pre>\n<h3 id=\"move-your-site-to-the-top-level\u00b6\">Move your site to the \u2018top level\u2019<a href=\"https:\/\/docs.bolt.cm\/4.0\/howto\/making-sure-htaccess-works#move-your-site-to-the-top-level\">\u00b6<\/a><\/h3>\n<p>If you\u2019re setting up Bolt in a subfolder and the previous tip doesn\u2019t work, you might try setting up Bolt in it\u2019s own subdomain, since that usually gives less problems. So, instead of using  <code>http:\/\/example.org\/testingbolt<\/code>, set it up as  <code>http:\/\/testingbolt.example.org\/<\/code>.<\/p>\n<h3 id=\"contact-your-webhost\u00b6\">Contact your webhost<a href=\"https:\/\/docs.bolt.cm\/4.0\/howto\/making-sure-htaccess-works#contact-your-webhost\">\u00b6<\/a><\/h3>\n<p>Ask your webhost what might be wrong. The more info you give them, the bigger the chance that they might be able to help you out.<\/p>\n<h3 id=\"use-a-pre-configured-build-of-apache\u00b6\">Use a pre-configured build of Apache<a href=\"https:\/\/docs.bolt.cm\/4.0\/howto\/making-sure-htaccess-works#use-a-pre-configured-build-of-apache\">\u00b6<\/a><\/h3>\n<p>If you\u2019re setting up Apache on your own computer, and it\u2019s turning out to be hard to configure, you should consider using  <a href=\"https:\/\/www.apachefriends.org\/index.html\">XAMPP<\/a>  (Windows),  <a href=\"https:\/\/www.mamp.info\/en\/\">MAMP<\/a>  (OS X) or  <a href=\"http:\/\/www.ampps.com\/\">AMPPS<\/a>  (Windows, OS X, Linux).<\/p>\n<h3 id=\"use-nginx-instead\u00b6\">Use Nginx instead<a href=\"https:\/\/docs.bolt.cm\/4.0\/howto\/making-sure-htaccess-works#use-nginx-instead\">\u00b6<\/a><\/h3>\n<p>If you\u2019re fed up with Apache\u2019s shenanigans, you might consider ditching it in favor of  <a href=\"http:\/\/nginx.org\/en\/download.html\">Nginx<\/a>. Nginx is a high-performance web server, that\u2019s actually easier to configure than Apache.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JUMP TO: Test if .htaccess is working Test if mod_rewrite is working My htaccess is broken? What do? Bolt makes extensive use of a common feature called \u2018url rewriting\u2019. This basically means that you can request a pretty url like \/page\/about-this-website in your browser, and behind the scenes your web server will just \u2018translate\u2019 this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[27,30],"class_list":["post-756","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-htaccess","tag-apache"],"_links":{"self":[{"href":"https:\/\/blog.pirulug.com\/index.php?rest_route=\/wp\/v2\/posts\/756","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.pirulug.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.pirulug.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.pirulug.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.pirulug.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=756"}],"version-history":[{"count":1,"href":"https:\/\/blog.pirulug.com\/index.php?rest_route=\/wp\/v2\/posts\/756\/revisions"}],"predecessor-version":[{"id":761,"href":"https:\/\/blog.pirulug.com\/index.php?rest_route=\/wp\/v2\/posts\/756\/revisions\/761"}],"wp:attachment":[{"href":"https:\/\/blog.pirulug.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.pirulug.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.pirulug.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}