{"id":5060,"date":"2020-04-24T17:51:35","date_gmt":"2020-04-24T17:51:35","guid":{"rendered":"https:\/\/lamp.ciscoar.com\/?page_id=5060"},"modified":"2020-04-24T23:20:03","modified_gmt":"2020-04-24T23:20:03","slug":"how-to-enable-apache-mod_rewrite","status":"publish","type":"page","link":"https:\/\/lamp.ciscoar.com\/?page_id=5060","title":{"rendered":"How to enable Apache mod_rewrite"},"content":{"rendered":"\n\n\n<h2 class=\"wp-block-heading\">What is Apache mod_rewrite?<\/h2>\n\n\n\n<p>Apache mod_rewrite provides a way to modify incoming URL requests, dynamically, based on regular expression rules. This allows you to map arbitrary URLs onto your internal URL structure in any way you like, you can take a look at the Apache&#8217;s website for more details at the following page:<\/p>\n\n\n<p class=\"fonts-plugin-block \" style=\"font-family: calibri;font-size: 20px;color: #9b51e0\"><a href=\"https:\/\/httpd.apache.org\/docs\/2.4\/rewrite\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/httpd.apache.org\/docs\/2.4\/rewrite\/<\/a><\/p>\n\n\n<h2 class=\"wp-block-heading\">Apache mod_rewrite and WordPress<\/h2>\n\n\n\n<p>You may wonder why do I have to learn about Apache mod_rewrite if I&#8217;m using WordPress? that really is a good question, and the answer comes when you start playing around with the <a href=\"\/how-to-get-rid-of-index-php-in-wordpress-url\/\" target=\"_blank\" rel=\"noreferrer noopener\">WordPress permalinks<\/a>, you must know that the changes you make there won&#8217;t take any effect if the <strong>Apache mod_rewrite<\/strong> is not enabled on your system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Enabling Apache mod_rewrite<\/h2>\n\n\n\n<p>Depending on your Linux distro, you&#8217;ll find that the Apache mod_rewrite could comes enabled (CentOS 7) or disabled (Linux Mint) by default, in this article we&#8217;re going to learn how to verify the status of the Apache mod_rewrite on Linux CentOS 7.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to verify that Apache mod_rewrite is enabled<\/h2>\n\n\n\n<p>CentOS 7 and other Red Hat based distros have an specific file where all the Apache&#8217;s modules are listed, to make sure that \u201c<strong>mod_rewrite<\/strong>\u201d is enabled on your&nbsp;<strong>Apache web server<\/strong>, you must take a look at the file called&nbsp;<strong>00-base.conf<\/strong>&nbsp;located at the following path.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"rest\" class=\"language-rest\">\/etc\/httpd\/conf.modules.d\/00-base.conf<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/linux-directory-tree-apache-mod_rewrite_v3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"699\" height=\"432\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/linux-directory-tree-apache-mod_rewrite_v3.png\" alt=\"\" class=\"wp-image-4718\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/linux-directory-tree-apache-mod_rewrite_v3.png 699w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/linux-directory-tree-apache-mod_rewrite_v3-300x185.png 300w\" sizes=\"auto, (max-width: 699px) 100vw, 699px\" \/><\/a><figcaption>Apache modules list file path<\/figcaption><\/figure>\n\n\n\n<p>If you are using&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/lamp.ciscoar.com\/winscp\/\" target=\"_blank\">WinSCP&nbsp;<\/a>then this step is just a piece of cake, on your Red Hat based OS (in our case CentOS 7) browse the folders until you reach the file, open it by double clicking over it, hit the binocular icon enter the keyword and voila!<\/p>\n\n\n<p class=\"fonts-plugin-block \" style=\"font-family: calibri;font-weight: 700;font-size: 20px;color: #9b51e0\">\/etc\/httpd\/conf.modules.d\/00-base.conf<\/p>\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/checking-mod_rewrite_apache_centos7.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"808\" height=\"678\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/checking-mod_rewrite_apache_centos7.jpg\" alt=\"\" class=\"wp-image-4657\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/checking-mod_rewrite_apache_centos7.jpg 808w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/checking-mod_rewrite_apache_centos7-300x252.jpg 300w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/checking-mod_rewrite_apache_centos7-768x644.jpg 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><figcaption>checking mod_rewrite \u2013 enabled OK<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Apache mod_rewrite enabled OK<\/h2>\n\n\n\n<p>If you find the hash symbol \u201c#\u201d before a line, it means that this particular module is \u201ccommented\u201d and therefore is not enabled, remove the \u201c#\u201d to enable the mode and close the file saving the changes, you must reload Apache after that change.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Reload Apache web server<\/h2>\n\n\n\n<p>In order to make this change to take effect you must reload Apache using the following CLI command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"rest\" class=\"language-rest\">systemctl restart httpd.service<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Where to go next?<\/h2>\n\n\n\n<p>Now that you are absolutely certain that Apache mod_rewrite is activated, you can test it creating a simple URL redirection, take a look at the following article to learn how. <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"\/apache-url-redirection\/\">How to create an .htaccess rule for URL redirection<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>What is Apache mod_rewrite? Apache mod_rewrite provides a way to modify incoming URL requests, dynamically, based on regular expression rules. This allows you to map arbitrary URLs onto your internal URL structure in any way you like, you can take a look at the Apache&#8217;s website for more details at the following page: Apache mod_rewrite &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lamp.ciscoar.com\/?page_id=5060\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to enable Apache mod_rewrite&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-5060","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/5060","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5060"}],"version-history":[{"count":26,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/5060\/revisions"}],"predecessor-version":[{"id":5161,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/5060\/revisions\/5161"}],"wp:attachment":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5060"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}