sphinx Posted March 14, 2013 Share Posted March 14, 2013 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 Link to comment https://forums.phpfreaks.com/topic/275663-htaccess-isnt-redirecting-as-i-want-it-too/ Share on other sites More sharing options...
sphinx Posted March 14, 2013 Author Share Posted March 14, 2013 For example, it would translate: oldwebsite.co.uk/basket.html?cdid=1234 too: newwebsite.com/basket.html Link to comment https://forums.phpfreaks.com/topic/275663-htaccess-isnt-redirecting-as-i-want-it-too/#findComment-1418656 Share on other sites More sharing options...
requinix Posted March 14, 2013 Share Posted March 14, 2013 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 https://forums.phpfreaks.com/topic/275663-htaccess-isnt-redirecting-as-i-want-it-too/#findComment-1418662 Share on other sites More sharing options...
sphinx Posted March 14, 2013 Author Share Posted March 14, 2013 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 Link to comment https://forums.phpfreaks.com/topic/275663-htaccess-isnt-redirecting-as-i-want-it-too/#findComment-1418668 Share on other sites More sharing options...
requinix Posted March 14, 2013 Share Posted March 14, 2013 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 https://forums.phpfreaks.com/topic/275663-htaccess-isnt-redirecting-as-i-want-it-too/#findComment-1418694 Share on other sites More sharing options...
sphinx Posted March 14, 2013 Author Share Posted March 14, 2013 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 Link to comment https://forums.phpfreaks.com/topic/275663-htaccess-isnt-redirecting-as-i-want-it-too/#findComment-1418702 Share on other sites More sharing options...
requinix Posted March 14, 2013 Share Posted March 14, 2013 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 https://forums.phpfreaks.com/topic/275663-htaccess-isnt-redirecting-as-i-want-it-too/#findComment-1418704 Share on other sites More sharing options...
sphinx Posted March 14, 2013 Author Share Posted March 14, 2013 I've put on my site: Try it: http://harrisnetwork.co.uk http://harrisnetwork.co.uk/1212 http://harrisnetwork.co.uk/12122 with .htaccess Seems to put weird symbols in. Thanks Link to comment https://forums.phpfreaks.com/topic/275663-htaccess-isnt-redirecting-as-i-want-it-too/#findComment-1418707 Share on other sites More sharing options...
requinix Posted March 14, 2013 Share Posted March 14, 2013 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 https://forums.phpfreaks.com/topic/275663-htaccess-isnt-redirecting-as-i-want-it-too/#findComment-1418718 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.