7

I would like it so that when the user goes to http://mysite.com/home that it redirects him to http://mysite.com/page.php?id=home. This is what I put in my .htaccess, but it doesn't seem to work.

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

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

Edit:

I've tried some rewrite I know work, so now I'm certain it's not that my problem. I checked with phpinfo() and yes, mod rewrite is running, I set up apache2 with LAMP, I'm running the latest version of Linux Mint.

Alexandre Hitchcox
  • 2,704
  • 5
  • 22
  • 33

2 Answers2

23

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

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

and then I modified AllowOverride None to AllowOverride all in the /var/www/ part of the 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>
simhumileco
  • 31,877
  • 16
  • 137
  • 115
Alexandre Hitchcox
  • 2,704
  • 5
  • 22
  • 33
4

This worked for me after removing the forward slash:

RewriteEngine On 
RewriteBase /test 
RewriteRule ^(.+)$ page.php?id=$1 [NC,L]
m79lkm
  • 2,960
  • 1
  • 22
  • 22
  • is page.php in your document root? if you are not in the document root directory you will also need to add a RewriteBase statement – m79lkm Mar 26 '13 at 20:59
  • edited my answer showing you my .htaccess file. Hope this helps! – m79lkm Mar 26 '13 at 21:04