Jump to content

.htaccess isn't redirecting as I want it too.


sphinx

Recommended Posts

Hello.

 

This is my current .htaccess file contents:

 

 

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldwebsite\.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldwebsite\.co.uk$
RewriteRule ^(.*)$ "http\:\/\/scripts\.newsite\.com\/AFClick\.asp\?blablaID\=111\&merchantID\=111\&programmeID\=111\&mediaID\=111\&tracking\=bla\&url\=http\:\/\/www\.newsite\.com\/$1" [R=301,L]
 

Bascially, at the moment, it'll copy anything after the domain trail ("/") over to newsite.com, but it doesn't seem to copy all characters over, so it won't accept the & symbol.

 

Is there a way I can make it copy everything exactly across?

 

Thanks

Edited by sphinx
Link to comment
Share on other sites

RewriteRule doesn't operate on the query string. You have to add that in yourself.

 

Try

RewriteEngine on
RewriteCond %{HTTP_HOST} =oldwebsite.co.uk [OR]
RewriteCond %{HTTP_HOST} =www.oldwebsite.co.uk
RewriteRule ^ http://scripts.newsite.com/AFClick.asp?blablaID=111&merchantID=111&programmeID=111&mediaID=111&tracking=bla&url=http://www.newsite.com%{REQUEST_URI} [R=301,L]
Link to comment
Share on other sites

Hi.

 

Replaced with that code, but for example it still does this:

 

 

 

 

http://oldsite.co.uk/basket.html?cdid=1234

 

Will translate to:

 

 

http://newsite.co.uk/basket.html

 

Thank you

Edited by sphinx
Link to comment
Share on other sites

Is it not escaping?...

RewriteRule ^ http://scripts.newsite.com/AFClick.asp?blablaID=111&merchantID=111&programmeID=111&mediaID=111&tracking=bla&url=http://www.newsite.com${escape:%{REQUEST_URI}} [R=301,L]
Can you tell exactly what URL you're being redirected to from here? Where at scripts.newsite.com you go, that is; it apparently will redirect to that "url" you pass in but I want to know what the URL for the first redirect is.
Link to comment
Share on other sites

I'll explain it more clearly with more simple URL's:

 

RewriteEngine on
RewriteCond %{HTTP_HOST} =oldwebsite.co.uk [OR] <<-- for this example, the entered URL will be: oldwebsite.co.uk/12345
RewriteCond %{HTTP_HOST} =www.oldwebsite.co.uk
RewriteRule ^ http://anotherwebsitetrack.com&url=http://www.newsite.com/12345 [R=301,L] <<-- I need it to go there, which '%{REQUEST_URI}' achieves but I need it to work with the '?' symbol as well, for example 12345?1 etc...

 

Hope that's easier.

Thanks

Edited by sphinx
Link to comment
Share on other sites

I understand what you're saying. That was never a problem.

 

You want to redirect to some website which then redirects to your new website. I'm asking, with the latest changes to the .htaccess, where does that first redirect actually send you? Where on the "some website" (anotherwebsitetrack.com, now) are you being sent? What is that URL?

Link to comment
Share on other sites

Because the URL it's redirecting to is wrong. Specifically, it needs a trailing slash after the domain name.

 

Does seem like escaping only happens to captured groups used in the replacement URL.

RewriteRule ^ http://mxtoolbox.com/?url=http://www.newsite.com${escape:%{REQUEST_URI}} [R=301,L]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.