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

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]

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.

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

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?

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.