Solved

htaccess rewrite with query string

Posted on 2012-04-05
12
308 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
 
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now