View Full Version : mod_rewrite loaded but not working

October 21st, 2009, 04:08 PM

I'm having a problem getting mod_rewrite to work on my home server.

I've setup linux-server on my home pc and have apache2-php-mysql all working fine and mod-rewrite is definately loaded in apache
(phpinfo shows it enabled, webadmin shows it as enabled and using the command line
sudo a2enmod rewrite also shows it enabled)

I'm using a test that I found here:

which works on my shared hosting, but not on my home server.
the .htaccess file contains:

RewriteEngine On

RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]

and a php script:


if($_GET['link']==1){echo"You are not using mod_rewrite";}

elseif($_GET['link']==2){echo"Congratulations!! You are using Apache mod_rewrite";}

else{echo"Linux Apache mod_rewrte Test Tutorial";}


This definitely works on my shared hosting, so I'm concluding that I have a problem with my apache2 config.

Another possible clue (I'm still a newbie at configuring apache)
is that when I try and restart apache from the terminal :

sudo service apache2 restart

I get the message: 'Could not not determine the servers fully qualified domain name, using for Servername'

but apache does restart ok and I can use the webserver on http://localhost without any problems, except for mod_rewrite

I'm sure it's a apache config problem

Any help appreciated.


October 21st, 2009, 04:46 PM

October 21st, 2009, 06:10 PM
Thankyou !

I inserted :
<Directory "/var/www/test">
AllowOverride ALL

into the apache config file and it works a treat


October 27th, 2009, 02:12 PM
Thanks for posting your solution. For anyone else looking for this, check out https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles