Rewriting URL does not seem to work. Apache2

I would like the user http://mysite.com/home to redirect him to http://mysite.com/page.php?id=home . This is what I put in my .htaccess, but it does not seem to work.

 RewriteEngine On RewriteRule ^/(.+)$ page.php?id=$1 [NC,L] 

It just sends me to the / home directory, with a good 404. Help is appreciated. Thanks.

Edit:

I tried to rewrite, I know the work, so now I am sure that this is not my problem. I checked with phpinfo() and yes, mod rewrite is running, I configured apache2 using LAMP, I am running the latest version of Linux Mint.

+7
source share
2 answers

Ok, I fixed the problem, this is how I did it.

sudo gedit /etc/apache2/sites-available/default

and then I changed AllowOverride None to AllowOverride all in the /var/www/ file

 <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride all #This was 'None' before, change it to 'all' Order allow,deny allow from all </Directory> 
+21
source

This worked for me after removing the slash:

 RewriteEngine On RewriteBase /test RewriteRule ^(.+)$ page.php?id=$1 [NC,L] 
+3
source

All Articles