Forum Moderators: phranque

Message Too Old, No Replies

Query string not coming through correctly

         

solnspace

6:21 am on Feb 25, 2009 (gmt 0)

10+ Year Member



I have a parked site pointing to the same content as my main site, and I am able to redirect 301 from the main site to the parked site. However, some of my PHP files that use query strings are not getting redirected properly. I read somewhere about the QSA tag to preserve Query Strings and tried it without any success.

My htaccess file looks like this:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.newdomain\.com
RewriteRule (.*) [newdomain.com...] [R=301,QSA,L]

For example, I am calling PHP from my Javascript file as follows:

$("#loginid").load("/server/myPHP.php?what=5",checkSessionIsActive);

If I echo the 'what' parameter inside my PHP file, I get it correctly as 5 without redirection. However, when I redirect, I get a blank.

I have been struggling with this for the last 2 - 3 days. Any help will be deeply appreciated.

Thanks

jdMorgan

12:29 pm on Feb 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mod_rewrite shouldn't be affecting your request. In fact, you don't even need to use the QSA flag on your rule, because the default mod_rewrite behavior is to pass query strings through without change.

If you are redirecting from one server or hosting account to another, be sure to check the mod_rewrite code on the other server/host as well; The query may be getting corrupted there.

You may have simplified the actual code and/or query for posting here. If so, be aware that certain characters cannot be used in URLs without being encoded. Other characters cannot be used in query strings unless they are encoded. Your script may need to handle un-encoding characters that Apache encodes during the redirect. A query of literally "what=5" should not present a problem, but if you've simplified your example too much, it may be hiding a problem.

Jim