11

I'm trying to enable mod_rewrite on an Amazon Linux instance. My Directory directives look like this:

<Directory />
    Order deny,allow
    Allow from all
    Options None
    AllowOverride None
</Directory>

<Directory "/var/www/vhosts">
    Order allow,deny
    Allow from all
    Options None
    AllowOverride All
</Directory>

And then further down in httpd.conf I have the LoadModule directive:

... other modules...
#LoadModule substitute_module modules/mod_substitute.so
LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule proxy_module modules/mod_proxy.so
... other modules...

I have commented out all the Apache modules not needed by Wordpress.

Still when I issue http restart and then check the loaded modules with /usr/sbin/httpd -l I get only:

[root@foobar]# /usr/sbin/httpd -l
Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c

Inside the virtual host containing the Wordpress site I have an .htaccess containing:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

The .htaccess is owned by apache which is the user apache runs under. The apachectl -t command returns Syntax OK

My /etc/httpd/conf.d/vhosts.conf looks like this:

<VirtualHost *:80>
     ServerAdmin [email protected]
     ServerName foobar.net
     ServerAlias www.foobar.net
     DocumentRoot /var/www/vhosts/foobar/
     ErrorLog /var/www/vhosts/foobar/logs/error.log
     CustomLog /var/www/vhosts/foobar/logs/access.log combined
</VirtualHost>

What am I doing wrong? What should I check?

4 Answers 4

6

The LoadModule directive will load a module dynamically.

Try issuing RewriteEngine on in a virtual host followed by apachectl -t to confirm weather or not the module is actually loaded.

5
  • Hi James, thanks for the answer I've added more detail to the question regarding what you pointed out. RewriteEngine is on and apachectl -t returns Syntax OK but still doesn't work.
    – Lorenzo
    Nov 5, 2012 at 16:37
  • Sorry I deleted my last comment it was wrong. You've taken this from the wordpress .htaccess file haven't you? Do you have AllowOverride all enabled in your VHost configuration? Nov 5, 2012 at 16:46
  • Hi James, yes I've taken it from WP. Yes the AllowOverride on the subdirectories of my DocumentRoot is set to All
    – Lorenzo
    Nov 5, 2012 at 16:48
  • 1
    Please try this: In the server configuration - not .htaccess add the lines RewriteEngine On and RewriteRule ^.*$ http://www.wordpress.org/ [R] to confirm if rewrite is functioning at all. It should pass all traffic to the Wordpress website. Nov 5, 2012 at 16:58
  • I deleted the .htaccess from WP and did the changes you suggested but it doesn't work.
    – Lorenzo
    Nov 5, 2012 at 17:24
5

I just started a fresh amazon linux and had the same issue and the Options FollowSymLink were there but the next line AllowOverride None had to be changed to AllowOverride All

0
4

My configuration was correct but I needed

Options FollowSymLink

in my DocumentRoot's declaration in httpd.conf for mod_rewrite to work.

4

I got the solution for this problem.....

I have changed AllowOverride None to AllowOverride all, below Options Indexes FollowSymLinks in the config file /etc/httpd/conf/httpd.conf

Thanks!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .