• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • 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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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