Reputation: 7012
The local wordpress website home page runs well but mod_rewrite
does not work. So, the home page works, but as soon as I click any link I get Not Found
.
Log output for this error:
[error] [client 127.0.0.1] File does not exist: /Applications/MAMP/htdocs/myweb/my-web-page-that-has-to-work, referer: http://myweb.dev/
As per my understanding, the error would mean that it looks for that specific page instead of using mod_rewrite
in order tot get the page from database.
httpd.conf
relevant content:
# Virtual hosts, uncommented include
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
...
# AllowOverride All is here
<Directory "/Applications/MAMP/htdocs">
Options All
AllowOverride All
Order allow,deny
Allow from all
XSendFilePath "/Applications/MAMP/htdocs"
</Directory>
httpd-vhosts.conf
relevant content:
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/myweb"
ServerName myweb.dev
ServerAlias www.myweb.dev
ErrorLog "/private/var/log/apache2/myweb-error_log"
CustomLog "/private/var/log/apache2/myweb-access_log" common
</VirtualHost>
Any clue on how to get it to work?
Upvotes: 3
Views: 25980
Reputation: 4506
If you want to enable mod_rewrite
for you MAMP installation you need to do the following:
/Applications/MAMP
so I'll use that but replace the comment with yours/Applications/MAMP/conf/apache/httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule rewrite_module modules/mod_rewrite.so
LoadModule rewrite_module modules/mod_rewrite.so
Upvotes: 1
Reputation: 1
Upvotes: 0
Reputation: 156
First make sure Apache loads the module. See: How to enable mod_rewrite for Apache 2.2
Then add this to an .htaccess file inside your folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
</IfModule>
or just add it to your httpd-vhosts.conf like this. CORRECTED:
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/myweb"
ServerName myweb.dev
ServerAlias www.myweb.dev
ErrorLog "/private/var/log/apache2/myweb-error_log"
CustomLog "/private/var/log/apache2/myweb-access_log" common
<Directory "/Applications/MAMP/htdocs/myweb">
AllowOverride All
Allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
</IfModule>
</Directory>
</VirtualHost>
Now add your rewrite rules for WP and see if it works.
You may check if Apache is loading the module with a PHP script inside your folder. Try this and proceed from there.
<?php
if (in_array('mod_rewrite', apache_get_modules())) {
echo "Yes, Apache supports mod_rewrite.";
}
else {
echo "Apache is not loading mod_rewrite.";
}
Upvotes: 5