{"id":5716,"date":"2014-04-06T10:29:01","date_gmt":"2014-04-06T10:29:01","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/06\/htaccess-rewrite-with-drupal-and-clean-urls-on-mamp-stack-collection-of-common-programming-errors\/"},"modified":"2014-04-06T10:29:01","modified_gmt":"2014-04-06T10:29:01","slug":"htaccess-rewrite-with-drupal-and-clean-urls-on-mamp-stack-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/06\/htaccess-rewrite-with-drupal-and-clean-urls-on-mamp-stack-collection-of-common-programming-errors\/","title":{"rendered":".htaccess rewrite with drupal and clean urls on mamp stack-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m having an unusual access problem with Drupal running on a MAMP stack. The Drupal install is working fine, so I know it&#8217;s not a Drupal issue. &#8220;Clean URLs&#8221; are working fine for anything with a single-level url, but nothing with 2+ path levels.<\/p>\n<p>For example:<\/p>\n<p>example.com\/foo, example.com\/bar, etc. All work perfectly.<\/p>\n<p>example.com\/foo\/bar, example.com\/bar\/foo\/bar, etc. Do <strong>not<\/strong> work.<\/p>\n<p>I get an access denied (not 404) page, served by Drupal, with the login boxes and site name, but no theme applied. (and, yes, I am actively logged in as admin \/ user 1) \ud83d\ude09<\/p>\n<p>If I disable &#8216;clean urls&#8217; everything works perfectly. I am assuming this has something to do with my rewrite rules in my htaccess, but have searched the net to no avail (including drupal&#8217;s site and irc channel).<\/p>\n<p>My current .htaccess is as follows:<\/p>\n<pre><code>#\n# Apache\/PHP\/Drupal settings:\n#\n\n# Protect files and directories from prying eyes.\n\n  Order allow,deny\n\n\n\n# Don't show directory listings for URLs which map to a directory.\nOptions -Indexes\n\n# Follow symbolic links in this directory.\nOptions +FollowSymLinks\n\n# Make Drupal handle any 404 errors.\nErrorDocument 404 \/index.php\n\n# Force simple error message for requests for non-existent favicon.ico.\n\n  # There is no end quote below, for compatibility with Apache 1.3.\n  ErrorDocument 404 \"The requested file favicon.ico was not found.\n\n\n# Set the default handler.\nDirectoryIndex index.php\n\n# Override PHP settings. More in sites\/default\/settings.php\n# but the following cannot be changed at runtime.\n\n# PHP 4, Apache 1.\n\n  php_value magic_quotes_gpc                0\n  php_value register_globals                0\n  php_value session.auto_start              0\n  php_value mbstring.http_input             pass\n  php_value mbstring.http_output            pass\n  php_value mbstring.encoding_translation   0\n\n\n# PHP 4, Apache 2.\n\n  php_value magic_quotes_gpc                0\n  php_value register_globals                0\n  php_value session.auto_start              0\n  php_value mbstring.http_input             pass\n  php_value mbstring.http_output            pass\n  php_value mbstring.encoding_translation   0\n\n\n# PHP 5, Apache 1 and 2.\n\n  php_value magic_quotes_gpc                0\n  php_value register_globals                0\n  php_value session.auto_start              0\n  php_value mbstring.http_input             pass\n  php_value mbstring.http_output            pass\n  php_value mbstring.encoding_translation   0\n\n\n# Requires mod_expires to be enabled.\n\n  # Enable expirations.\n  ExpiresActive On\n\n  # Cache all files for 2 weeks after access (A).\n  ExpiresDefault A1209600\n\n  \n    # Do not allow PHP scripts to be cached unless they explicitly send cache\n    # headers themselves. Otherwise all scripts would have to overwrite the\n    # headers set by mod_expires if they want another caching behavior. This may\n    # fail if an error occurs early in the bootstrap process, and it may cause\n    # problems if a non-Drupal PHP file is installed in a subdirectory.\n    ExpiresActive Off\n  \n\n\n# Various rewrite rules.\n\n  RewriteEngine on\n\n  # If your site can be accessed both with and without the 'www.' prefix, you\n  # can use one of the following settings to redirect users to your preferred\n  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:\n  #\n  # To redirect all users to access the site WITH the 'www.' prefix,\n  # (http:\/\/example.com\/... will be redirected to http:\/\/www.example.com\/...)\n  # adapt and uncomment the following:\n  # RewriteCond %{HTTP_HOST} ^example\\.com$ [NC]\n  # RewriteRule ^(.*)$ http:\/\/www.example.com\/$1 [L,R=301]\n  #\n  # To redirect all users to access the site WITHOUT the 'www.' prefix,\n  # (http:\/\/www.example.com\/... will be redirected to http:\/\/example.com\/...)\n  # uncomment and adapt the following:\n  # RewriteCond %{HTTP_HOST} ^www\\.example\\.com$ [NC]\n  # RewriteRule ^(.*)$ http:\/\/example.com\/$1 [L,R=301]\n\n  # Modify the RewriteBase if you are using Drupal in a subdirectory or in a\n  # VirtualDocumentRoot and the rewrite rules are not working properly.\n  # For example if your site is at http:\/\/example.com\/drupal uncomment and\n  # modify the following line:\n  # RewriteBase \/drupal\n  #\n  # If your site is running in a VirtualDocumentRoot at http:\/\/example.com\/,\n  # uncomment the following line:\n  RewriteBase \/\n\n  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.\n  RewriteCond %{REQUEST_FILENAME} !-f\n  RewriteCond %{REQUEST_FILENAME} !-d\n  RewriteCond %{REQUEST_URI} !=\/favicon.ico\n  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]\n\n\n# $Id: .htaccess,v 1.90.2.5 2010\/02\/02 07:25:22 dries Exp $\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m having an unusual access problem with Drupal running on a MAMP stack. The Drupal install is working fine, so I know it&#8217;s not a Drupal issue. &#8220;Clean URLs&#8221; are working fine for anything with a single-level url, but nothing with 2+ path levels. For example: example.com\/foo, example.com\/bar, etc. All work perfectly. example.com\/foo\/bar, example.com\/bar\/foo\/bar, etc. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5716","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5716","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5716"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5716\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}