rewriting dynamic get strings to another script.

Using mod_rewrite to handle various content issues

rewriting dynamic get strings to another script.

Postby NGinuity » Mon Jul 23, 2007 4:00 pm

Hello Everyone!

I am trying to figure out how to do something that sounds fairly simple, but just can't get it to do what I want.

I have a condition set up where I am redirecting all of my php scripts back through index.php:

RewriteCond $1 !^(index.php) [NC]
RewriteRule ^([^/]*\.php) \
index.php?page=$1 [PT,L]

Now, a slight problem. I am trying to pass all of the $_GET variables from that URL string into the index.php page as well.

For instance
I want callingscript.php?variable1=blah&variable2=blahblah.....

to translate to:

index.php?page=callingscript.php&variable1=blah&variable2=blahblah.....

Note that there is no pre-defined number of variables being sent, it could be any number.

I changed the above rule to look like this, but it throws 500 errors, or, it doesn't work as expected:

RewriteCond $1 !^(index.php) [NC]
RewriteRule ^([^/]*\.php)\?(.*) \
index.php?page=$1&$2 [PT,L]

Can someone shed some light on what to do here?

Thank you!
NGinuity
 
Posts: 2
Joined: Mon Jul 23, 2007 3:50 pm

Postby NGinuity » Mon Jul 23, 2007 4:07 pm

I think I figured it out....I tacked on a QSA after reading the tutorial here.....that would do it I guess??
NGinuity
 
Posts: 2
Joined: Mon Jul 23, 2007 3:50 pm

Postby richardk » Tue Jul 24, 2007 2:15 pm

Yes.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond $1 !^index\.php$ [NC]
RewriteRule ^([^/]+\.php)$ ./index.php?page=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Content

Who is online

Users browsing this forum: No registered users and 13 guests

cron