Domain Empire

Htaccess rewrite and GET variables

Spaceship Spaceship
Watch
I am trying to get variables from URLs, rewritten by htaccess and which are passed on using GET.

At the moment I have:

PHP:
Options +FollowSymLinks
RewriteEngine On

RewriteRule ^eating-out.php?sort=(.+)&page=(.*)$ dev1.php?cat=1&sort=$1&page=$2

Which is getting me a 404 error page when I access eating-out.php.. meaning the page isn't found.

However, if I use this:

PHP:
Options +FollowSymLinks
RewriteEngine On

RewriteRule ^eating-out.php dev1.php?cat=1

And try and access eating-out.php?page=2 it won't work.. the value of $_GET['page'] is still nothing.

Any ideas?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
The first one isn't working because sort and page are part of the query strings.

You should only need to add [QSA] to append the query string to the second rewrite:

Code:
RewriteRule ^eating-out.php dev1.php?cat=1 [QSA]

or better yet

Code:
RewriteRule ^eating\-out\.php$ /dev1.php?cat=1 [L,QSA]
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back