{"id":614,"date":"2014-03-05T15:11:42","date_gmt":"2014-03-05T15:11:42","guid":{"rendered":"http:\/\/thejoyofstick.com\/blog\/?p=614"},"modified":"2014-03-05T15:11:42","modified_gmt":"2014-03-05T15:11:42","slug":"apache2-rewrite-rules-are-not-working","status":"publish","type":"post","link":"https:\/\/thejoyofstick.com\/blog\/2014\/03\/05\/apache2-rewrite-rules-are-not-working\/","title":{"rendered":"Apache2 rewrite rules are not working"},"content":{"rendered":"<p>You have just edited your <code>.htaccess<\/code> on the root of your new site with RewriteRules and it&#8217;s not working. Something like this for a WordPress installation<\/p>\n<pre lang=\"linux\">\n<IfModule mod_rewrite.c>\nRewriteEngine On\nRewriteBase \/blog\/\nRewriteRule ^index\\.php$ - [L]\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule . \/blog\/index.php [L]\n<\/IfModule>\n<\/pre>\n<p>There are two reasons for this to happen. The <code>mod_rewrite<\/code> is not enabled by default and your configuration may not allow the use of <code>.htaccess<\/code><\/p>\n<h2>Enabling <code>mod_rewrite<\/code><\/h2>\n<p>As I usually don&#8217;t mess with Apache I often forget it has a command to enable modules. It&#8217;s just like this.<\/p>\n<pre>\nsudo a2enmod rewrite\n<\/pre>\n<h2>Enabling <code>.htaccess<\/code> files<\/h2>\n<p>Edit your site configuration file under <code>\/etc\/apache2\/sites-available\/<\/code>. At the <code>Directory<\/code> entry for your site files you need to allow the reading of directives in <code>.htaccess<\/code> files.<\/p>\n<p>If you were editing the default site <\/p>\n<pre lang=\"linux\">\n        <Directory \/var\/www\/>\n                Options Indexes FollowSymLinks MultiViews\n                AllowOverride None\n                Order allow,deny\n                allow from all\n        <\/Directory>\n<\/pre>\n<p>you would have to use <code>AllowOverride FileInfo<\/code> or even <code>AllowOverride All<\/code>. It&#8217;s your choice.<\/p>\n<h2>Get it to work<\/h2>\n<p>Finally you have to restart the Apache server to activate the changes<\/p>\n<pre>\nsudo service apache2 restart\n<\/pre>\n<p>That&#8217;s it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You have just edited your .htaccess on the root of your new site with RewriteRules and it&#8217;s not working. Something like this for a WordPress installation RewriteEngine On RewriteBase \/blog\/ RewriteRule ^index\\.php$ &#8211; [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d&hellip; <a href=\"https:\/\/thejoyofstick.com\/blog\/2014\/03\/05\/apache2-rewrite-rules-are-not-working\/\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,4],"tags":[62,74,73],"class_list":["post-614","post","type-post","status-publish","format-standard","hentry","category-linux","category-ubuntu","tag-apache2","tag-htaccess","tag-mod_rewrite"],"jetpack_shortlink":"https:\/\/wp.me\/pcmwlL-9U","jetpack_sharing_enabled":true,"jetpack_likes_enabled":false,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/thejoyofstick.com\/blog\/wp-json\/wp\/v2\/posts\/614","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thejoyofstick.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thejoyofstick.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thejoyofstick.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thejoyofstick.com\/blog\/wp-json\/wp\/v2\/comments?post=614"}],"version-history":[{"count":8,"href":"https:\/\/thejoyofstick.com\/blog\/wp-json\/wp\/v2\/posts\/614\/revisions"}],"predecessor-version":[{"id":622,"href":"https:\/\/thejoyofstick.com\/blog\/wp-json\/wp\/v2\/posts\/614\/revisions\/622"}],"wp:attachment":[{"href":"https:\/\/thejoyofstick.com\/blog\/wp-json\/wp\/v2\/media?parent=614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thejoyofstick.com\/blog\/wp-json\/wp\/v2\/categories?post=614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thejoyofstick.com\/blog\/wp-json\/wp\/v2\/tags?post=614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}