asgsoft Posted May 11, 2010 Share Posted May 11, 2010 I am trying to get variables from URLs, rewritten by htaccess and which are passed on using GET. At the moment I have: 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: 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? Quote Link to comment https://forums.phpfreaks.com/topic/201394-htaccess-rewrite-and-get-variables/ Share on other sites More sharing options...
cags Posted May 11, 2010 Share Posted May 11, 2010 A RewriteRule only matches against the REQUEST_URL, which doesn't include the QUERY_STRING, therefore the later part of your Rule can never match. If you need to only match certain patterns then you can use RewriteCond however given the pattern you have there you probably don't need to do that. You only seem to be passing over the same GET variables with one extra one, as such you should be able to use something like this... RewriteRule ^eating-out.php$ /dev1.php?cat=1 [QSA] If it isn't working try adding in a R flag so you can see where the page is being direct to, this will help you to debug (change the bit at the end to [QSA,R=302]). Quote Link to comment https://forums.phpfreaks.com/topic/201394-htaccess-rewrite-and-get-variables/#findComment-1056717 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.