Reputation: 109
I'm running an Apache server on my computer through MAMP, and I can't seem to get it to read my .htaccess
file. All of the solutions I've looked at have said to make sure that my AllowOverride
is set to All
in httpd.conf
, which it is, but this doesn't seem to resolve my issue. I know that .htaccess
isn't being read since I've written some nonsense at the start of the file and no error is being produced. I have also restarted the Apache servers after changing httpd.conf
. Maybe the problem is that I'm not completely sure where I'm supposed to place the .htaccess
file.
My MAMP document root was formerly MAMP > htdocs
, but I changed it to Library > WebServer > Documents
, which is where all of my PHP files are located. The current project I'm working on is a subdirectory of this, say Library > WebServer > Documents > project
. This is the folder that contains my .htaccess
file. My httpd.conf
file is in MAMP > conf > apache
, and the relevant section of it is as follows:
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
Do I need to change the directory from /
to something else to get this working? Any help is really appreciated.
Edit: I added the following <VirtualHost>
block to my httpd.conf
following the comments below, but again, nothing seems to change:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName localhost:8890
DocumentRoot /
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Update (Solved): I was able to resolve the issue by reverting MAMP's DocumentRoot
to its original MAMP > htdocs
as opposed to my Library > WebServer > Documents
. Apache is now reading the .htaccess
file located in my MAMP > htdocs > project
. Thanks everyone for the help.
Upvotes: 3
Views: 4409
Reputation: 3334
First I would try to fix my VirtualHost to use the correct paths. I'm not super familiar with Mac, but if Library > WebServer > Documents > project
corresponds to /Library/WebServer/Documents/project
in your file system, then I would use that. Might be /home/your_username/Library/WebServer/Documents/project
but as I said, I'm not a Mac guy. Next, I don't understand why you have directives for the same directory with opposite permissions, so I would try to remove the first Directory block or change the targetted directory to something else on one of the blocks. Note that you should never grant access to /
with apache as it would be a very big security breach.
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName localhost:8890
DocumentRoot /Library/WebServer/Documents/project
<Directory />
AllowOverride none
Require all denied
</Directory>
<Directory /Library/WebServer/Documents/project>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
If it still doesn't work, you might want to make sure that the filename Apache is looking for hasn't been changed to something else using the AccessFileName
directive.
Also, you are not giving details on where you put the VirtualHost
block, but if it is in a separate file. Make sure you are including that file somehow.
You don't specify your Apache version but since version 2.4, you should Require
instead of Allow
directives since this is deprecated. See https://httpd.apache.org/docs/2.4/en/howto/access.html
Upvotes: 3
Reputation: 4534
Check your httpd.conf
. Via the AllowOverride (http://httpd.apache.org/docs/current/mod/core.html#allowoverride) and AllowOverrideList (http://httpd.apache.org/docs/current/mod/core.html#allowoverridelist) directives it can control whether or not .htaccess
files are considered.
When this directive (i.e. AllowOverride) is set to None and AllowOverrideList is set to None, .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem.
Please note that the default value is None
for both, which cause exactly this behavior of not considering .htaccess
files.
Upvotes: 4
Reputation: 2789
Try adding Listen 80
and Listen 443
to the top of the main config.
Upvotes: 3