Solved

htaccess rewrite with query string

Posted on 2012-04-05
12
331 Views
Last Modified: 2012-04-14
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
Comment
Question by:Kyle Hamilton
  • 7
  • 5
12 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 37815186
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
 
LVL 25

Author Comment

by:Kyle Hamilton
ID: 37815681
Still no luck. I don't get redirected.

location goes to:

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

and stays there...
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 37819233
> location goes to:
 and what's the problem? that's exactly what you asked for
0
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
LVL 25

Author Comment

by:Kyle Hamilton
ID: 37819250
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 37822648
RewriteRule ^/admin/redirect\.php http://visitbordentown.com/admin/edit-event.php [QSA,L]
0
 
LVL 25

Author Comment

by:Kyle Hamilton
ID: 37824097
still no luck... :/
0
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 500 total points
ID: 37824537
can you please check access.log and error.log on the corresponding server
0
 
LVL 25

Author Comment

by:Kyle Hamilton
ID: 37824852
There's no error in the error.log for today...
0
 
LVL 25

Author Comment

by:Kyle Hamilton
ID: 37824867
what's puzzling me is that the redirect works fine if there is no query string...
0
 
LVL 25

Accepted Solution

by:
Kyle Hamilton earned 0 total points
ID: 37824979
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 37824980
> .. 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
 
LVL 25

Author Closing Comment

by:Kyle Hamilton
ID: 37845948
I appreciate the help. I still don't understand what makes it work, but so be it...
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question