Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URL Rewrite - $_GET variable not passing through

I have a simple rewrite that changes

http://website.com/page.php?id=1

into

http://website.com/page/1

using the following rewrite

RewriteRule ^page/(\d+)/?$ /page.php?id=$1 [L]

The rewrite works, it displays the page (i don't get a 404), but it doesn't appear to be passing through the id from the URL.

To test this I basically echoed the $_GET['id'] and nothing was returned.

Does anyone know why I might be going wrong?

Many thanks

like image 915
Oliver Evans Avatar asked Feb 15 '23 02:02

Oliver Evans


1 Answers

This is most likely due to enabling of MultiViews which runs before mod_rewrite and rewrites /page to /page.php.

Add this line on top of your .htaccess to disable it:

Options -MultiViews
like image 131
anubhava Avatar answered Feb 26 '23 08:02

anubhava