Page 1 of 1
need help with redirect to different domain
Posted: Sat Aug 13, 2011 7:14 am
by lastchild
I'm trying to redirect a web site to a different domain. For some reason, the URL that I put inside the htaccess for the new domain is altered when I try to go to the old domain.
It changes the new domain's URL when loaded in the browser from this:
http://www.newdomain.com/gdProfile.php?clientID=23
To this which is incorrect:
http://www.newdomain.com/index.php?clientID=noneOrNAN
I've tried the hosts cpanel redirect feature, and manually edited the .htaccess file, and both give the same results.
Here is what I used for the manual editing of the htaccess..
Code: Select all
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/gdProfile.php?clientID=23/$1 [R=301,L]
There is nothing else in the .htaccess file.
What on earth is causing this??
Thanks!
Re: need help with redirect to different domain
Posted: Sat Aug 13, 2011 2:21 pm
by twinedev
The way you have it written, you are adding the request on the old server to the URL of the redirect:
In your rewrite rule,
The (.*) says to capture all of the request (after the domain)
The $1 indicated use a back reference to the first captured match (everything)
ex:
http://www.olddomain.com/greg redirects you to:
http://www.newdomain.com/gdProfile.php?clientID=23/greg
If this is NOT what you want, then you need to change your rule.
Use a tool like http://www.fiddler2.com/fiddler2/ to monitor what requests are being made when you browse to the old address, then you can see if perhaps you are getting to the new site, it doesn't like the information after clientID=23 and is redirecting because of it.
Re: need help with redirect to different domain
Posted: Sat Aug 13, 2011 4:04 pm
by lastchild
Thanks. I don't know what to do to correct it though. I can usually use some htaccess code that I find online to do the job, but for some reason this is not working. Not even when I use the utility in my host's control panel. How should it be?
Re: need help with redirect to different domain
Posted: Sat Aug 13, 2011 4:52 pm
by twinedev
Do you want is to that no matter when they enter, it takes them strictly to
http://www.newdomain.com/gdProfile.php?clientID=23
If so, on then on your RewrtieRule, towards the end, get rid of the
/$1
-Greg
Re: need help with redirect to different domain
Posted: Sun Aug 14, 2011 2:01 pm
by lastchild
Greg,
I'm getting the same results -
http://www.newdomain.com/index.php?clientID=noneOrNAN
This is what I have:
Code: Select all
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/gdProfile.php?clientID=23 [R=301,L]
Isn't it strange that when I add the new domain URL in the redirect utility feature of my hosting cpanel that I get the same results? I've never seen this type of issue before where the new URL is rejected and rewritten.
Thanks