Htaccess rewrite and GET variables

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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
Close
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back