Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

htaccess rewrite with query string

Posted on 2012-04-05
12
Medium Priority
?
356 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

 
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 1500 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

688 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