55

I am trying to get the .htaccess working in MAMP. The content of the .htaccess is a simple redirect line, but the entire .htaccess file seems to have no effect, even when I change it to contain invalid data.

Is there any settings within MAMP I need to change to enable .htaccess files?

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
aurel
  • 3,082
  • 10
  • 44
  • 56

6 Answers6

103
  1. In httpd.conf on /Applications/MAMP/conf/apache, find:

    <Directory />
        Options Indexes FollowSymLinks
        AllowOverride None
    </Directory>
    
  2. Replace None with All.

  3. Restart MAMP servers.

Jonathan Simonney
  • 585
  • 1
  • 11
  • 25
Emanuil Rusev
  • 34,563
  • 55
  • 137
  • 201
  • 2
    Thank you! Every other comment I found about this issue had to do with updating permalinks, and I knew that wasn't my problem. This solved it! – Tania Rascia Jul 24 '15 at 14:58
  • 3
    for debugging, immediately check if your .htaccess file is consulted, at all. the easiest way to do this is to place garbage into it. this should give a '500 server error'. Then proceed to put in what you really want. (Also, in the directive, you may want a `RewriteEngine On`) – ivo Welch Sep 28 '15 at 22:49
  • 1
    Great solution. I tried all the other suggestions starting with simply saving the permalink setting in WP. Then was lead here and this solution worked. – Sal B Jul 04 '17 at 22:00
  • Thanks! This was really odd. I upgraded to MAMP 4.2 a few days ago and everything was working fine. Then I revisited today after a few days and it didn't work anymore. This solved it, but I have no idea how the MAMP httpd.conf file could have changed between then and now as I haven't touched this project or MAMP since it was working. – zeusstl Dec 26 '17 at 23:17
  • Great! Watch out in httpd.conf because there are a few similar lines. In MAMP 4 its the line under "# First, we configure the "default" to be a very restrictive set of # features." :) – Leon Mar 06 '18 at 08:21
  • This appears to be a thing, with CraftCMS and MAMP, in 2021. Thanks for the answer, will report back if there is a cleaner way without changing a low level MAMP file. – 3Easy Jan 07 '21 at 14:58
41

Go to httpd.conf on /Applications/MAMP/conf/apache and see if the LoadModule rewrite_module modules/mod_rewrite.so line is un-commented (without the # at the beginning)

and change these from ...

<VirtualHost *:80>
    ServerName ...
    DocumentRoot /....
</VirtualHost>

To this:

<VirtualHost *:80>
    ServerAdmin ...
    ServerName ...

    DocumentRoot ...
    <Directory ...>
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory ...>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>
Trisped
  • 5,705
  • 2
  • 45
  • 58
salahy
  • 1,177
  • 9
  • 9
7

I'm using MAMP (downloaded today) and had this problem also. The issue is with this version of the MAMP stack's default httpd.conf directive around line 370. Look at httpd.conf down at around line 370 and you will find:

<Directory "/Applications/MAMP/bin/mamp">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

You need to change: AllowOverride None To: AllowOverride All

qommander
  • 73
  • 2
  • 6
5

If you have MAMP PRO you can set up a host like mysite.local, then add some options from the 'Advanced' panel in the main window. Just switch on the options 'Indexes' and 'MultiViews'. 'Includes' and 'FollowSymLinks' should already be checked.

strangerpixel
  • 798
  • 1
  • 11
  • 27
  • 1
    Thanks...it looks like MAMP PRO has updated and these checkboxes are now on the `Hosts` page, under the `Extended` tab – Dan Jul 14 '14 at 14:18
5

The problem I was having with the rewrite is that some .htaccess files for Codeigniter, etc come with

RewriteBase /

Which doesn't seem to work in MAMP...at least for me.

SomethingOn
  • 9,813
  • 17
  • 68
  • 107
  • 2
    What should I use instead of /? I'm having a similar issue with an htaccess file, but modrewrite works for other projects on my localhost. – rmmoul Oct 31 '13 at 03:21
  • Commenting out the `RewriteBase` would be a solution to specific things within .htaccess not working, but not a solution to .htaccess not being read at all. – Stephen Ostermiller May 17 '22 at 11:34
0

I have MAMP v 6.6.2 (year 2022), and I was trying to make working php friendly URLs on my localhost Apache, by adding '.htaccess' file to my website root directory ("localhost/mywebsite/.htaccess"):

RewriteEngine On   
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?id=$1 [L,QSA]  

Which didn't work. But I tested it on cPanel hosting on a real domain and it worked fine.

So I have tried to change httpd.conf with these advises:

  1. https://stackoverflow.com/a/21411933/3936149 - didn't help
  2. https://stackoverflow.com/a/7670598/3936149 - didn't help
  3. https://stackoverflow.com/a/19204983/3936149 - didn't help

In the end I came up to an advise:

I simply commented out the second line of the code in my '.htaccess' (located at "localhost/mywebsite/.htaccess") file and that's it:

RewriteEngine On   
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?id=$1 [L,QSA]  

After it started to work I reverted all the changes in httpd.conf file, I have done above, and it was still working.

Yarik
  • 742
  • 8
  • 13