Solved

htaccess rewrite with query string

Posted on 2012-04-05
12
320 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
phpmyadmin installation 3 59
PHP Upload using Uploadify 4 90
Clearing cache in word press. 3 57
ignore other .htaccess 2 43
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
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.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

806 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