Failing to enable mod_rewrite on Ubuntu 10.10
I have apache2 installed, have run 'a2enmod rewrite' and /etc/init.d/apache2 restart' multiple times, but I can't seem to get mod_rewrite to work.
I looked at my phpinfo page and mod_rewrite is listed as a loaded module.
However, when I try even the simplest Rewrite rules, they simply don't work.
Here is my .htaccess file located in /var/www/.htaccess
RewriteEngine on
RewriteRule ^2227/$ index.php?s=2227 [L]
When I visit /index.php?s=2227, my site loads fine, but visiting /2227 just brings me to a 404 page and my Apache error logs reflect this saying:
File does not exist: /var/www/2227
I have my chmod 775'd my .htaccess file.
Is there anything here that I'm missing or any reason at all why mod_rewrite wouldn't be working for me in this instance?
12 Replies
<directory var="" www="">AllowOverride All</directory>
and (from
<directory>Options FollowSymLinks
AllowOverride AuthConfig FileInfo Indexes Limit Options=All,MultiViews
Order deny,allow
Deny from all</directory>
Is there anything else I could be missing?
@mikepink:
Has anybody managed to get mod_rewrite working on their Linode boxes?
Yes
I'm running Debian, but that's what Ubuntu is based off of.
sudo a2enmod rewrite
That's it. I run a couple sites that have several different versions of Gallery
If anyone has time, would you mind looking at my phpinfo and seeing if there's anything glaringly wrong with it that might prevent mod_rewrite from working?
removing /var/www/.htaccess
putting my rewrite rules in /etc/apache2/httpd.conf
editing my virtual hosts file to turn on the RewriteEngine and setting RewriteOptions to Inherit
restarting apache
This works, but everytime I want to change a rewrite rule, I need to restart Apache. It's not ideal, but it gets the job done.
Since you got rewrites working in httpd.conf it is sort of looking like the module is being loaded but your .htaccess files aren't being read. Can you try other directives in .htaccess and see if they work?
In /etc/apache2/apache2.conf I have
AccessFileName .htaccess
I'm assuming you have that - but it's worth checking.
Then in my /etc/apache2/sites-available/ I have all my vhosts files. Inside those are the directives for each vhost. Inside the
You might do a:
find /etc/apache2 | xargs grep "AllowOverride None"
just to see if anything in your Apache folder is turning overrides off? Hope that helps. I know this stuff can be kind of maddening (and writing the rules themselves can be an entire new, uh, "process"!)