Anti-Moronic Posted January 21, 2010 Share Posted January 21, 2010 Not sure if I'm going about this the right way. Here are my htaccess rules: rewriterule ^([^/]+)/$ /index.php?v1=$1 rewriterule ^([^/]+)/([^/]+)/$ index.php?v1=$1&v2=$2 rewriterule ^([^/]+)/([^/]+)/([^/]+)/$ index.php?v1=$1&v2=$2&v3=$3 rewriterule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ index.php?v1=$1&v2=$2&v3=$3&v4=$4 ..and I'm using this for my app to process pages, get requests etc. But is it possible to append another manual get query (in browser) to the already rewritten url. For example, this works: site.com/page1/tab1/ but I want to be able to process other get requests to any url like this: site.com/page1/tab1/?var1=abc or site.com/page1/?var1=abc etc etc -- Any ideas? I get a 404 obviously, but is there a better rule or set of rules which will help me achieve this? Any help greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/189260-mod_rewrite-question-appending-get-variables-to-already-rewritten-url-and/ Share on other sites More sharing options...
cags Posted January 21, 2010 Share Posted January 21, 2010 First off I'm very novice at mod_rewrite, so I'm just giving you some general tips that may help you get the solution. The query string is parsed separately to the actual URL so as such won't be parsed specifically by the rewriterule. I would imagine they automatically stay on the end of your url unless you change them. I can't do any tests for you as I've not yet figured out how to work with .htaccess files on my Win7 machine (they currently don't show up, need to play around), but the first step I would take is to add [R] to the end of your rules. This will change the address bar in your browser to the page Apache is trying to serve up to you. Hopefully this will highlight an error, if not try posting the outcome (i.e. the value in the address bar) on here and I'll have a quick look for you. Quote Link to comment https://forums.phpfreaks.com/topic/189260-mod_rewrite-question-appending-get-variables-to-already-rewritten-url-and/#findComment-999287 Share on other sites More sharing options...
wildteen88 Posted January 21, 2010 Share Posted January 21, 2010 You'll want to use to the QSA flag. Quote Link to comment https://forums.phpfreaks.com/topic/189260-mod_rewrite-question-appending-get-variables-to-already-rewritten-url-and/#findComment-999490 Share on other sites More sharing options...
cags Posted January 21, 2010 Share Posted January 21, 2010 Wouldn't have thought that would solve his error message, but certainly answers the question asked. Good to know, I'll add that to my notebook. Quote Link to comment https://forums.phpfreaks.com/topic/189260-mod_rewrite-question-appending-get-variables-to-already-rewritten-url-and/#findComment-999514 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.