Jump to content

Mod_Rewrite question - appending get variables to already rewritten url and..


Recommended Posts

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.

 

 

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.