Solved

htaccess rewrite with query string

Posted on 2012-04-05
12
346 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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

Limited time offer using promo code EXPERTS25

Designed with a wealth of functionality and convenience, ATEN's new Thunderbolt™ 2 Sharing Switch takes your Thunderbolt setup to the next level. Now through August 31, 2017, Experts Exchange members get 25% off the US7220 on the ATEN USA eShop using promo code EXPERTS25.

Question has a verified solution.

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

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

630 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