Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 363
  • Last Modified:

htaccess rewrite with query string

I have this php script which contains this line:

header('Location: redirect.php?eid='.$id);

Open in new window


In my .htaccess file, i have:

RewriteEngine On
Options +FollowSymlinks
RewriteRule ^redirect\.php$ http://visitbordentown.com/admin/edit-event.php [L]

Open in new window


I want the user to be redirected to:
http://visitbordentown.com/admin/edit-event.php?eid=xx

but the redirect doesn't work, and just I'm taken to redirect.php?eid=xx

(The redirect was working fine before I tried to pass the query string)

Thanks,
Kyle
0
Kyle Hamilton
Asked:
Kyle Hamilton
  • 7
  • 5
2 Solutions
 
ahoffmannCommented:
RewriteRule ^redirect\.php http://visitbordentown.com/admin/edit-event.php [QSA,L]

as a RewriteCond is missing, I guess you probably want:

RewriteRule ^/+redirect\.php http://visitbordentown.com/admin/edit-event.php [QSA,L]

Note: these rules assume that they match after your php script sended the Location: redirect
0
 
Kyle HamiltonData ScientistAuthor Commented:
Still no luck. I don't get redirected.

location goes to:

http://visitbordentown.com/admin/redirect.php?eid=49

and stays there...
0
 
ahoffmannCommented:
> location goes to:
 and what's the problem? that's exactly what you asked for
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Kyle HamiltonData ScientistAuthor Commented:
No, that's not what I'm looking for.

in the .htaccess file I want to redirect the following:

http://visitbordentown.com/admin/redirect.php?eid=xx

to :

http://visitbordentown.com/admin/edit-event.php?eid=xx
0
 
ahoffmannCommented:
RewriteRule ^/admin/redirect\.php http://visitbordentown.com/admin/edit-event.php [QSA,L]
0
 
Kyle HamiltonData ScientistAuthor Commented:
still no luck... :/
0
 
ahoffmannCommented:
can you please check access.log and error.log on the corresponding server
0
 
Kyle HamiltonData ScientistAuthor Commented:
There's no error in the error.log for today...
0
 
Kyle HamiltonData ScientistAuthor Commented:
what's puzzling me is that the redirect works fine if there is no query string...
0
 
Kyle HamiltonData ScientistAuthor Commented:
I don't know why this is working now, but this seems to have done it:

RewriteRule redirect.php http://visitbordentown.com/admin/edit-event.php [R=303]
0
 
ahoffmannCommented:
> .. that the redirect works fine if there is no query string
please post the entry from the working redirect from access.log
the other one, with query string, must be in access.log or error.log, otherwise you most likely checked the wrong server
0
 
Kyle HamiltonData ScientistAuthor Commented:
I appreciate the help. I still don't understand what makes it work, but so be it...
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now