Reputation: 63
I want to redirect with .htaccess
http://www.site1.com/pages/?url=http://www.gooogle.com/xyz/jkjk.html
to
http://tracking.site2.com/s?key=123456789&url=http://www.gooogle.com/xyz/jkjk.html
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/pages/?$
RewriteCond %{QUERY_STRING} ^url=(.+)$
RewriteRule ^(.*)$ http://tracking.site2.com/s?key=123456789&url=$1 [R=301,L]
Tried this.. failed. Please help me with this
Upvotes: 1
Views: 69
Reputation:
If you want the query string, add an additional flag of QSA (Query String Append) like so: [R=301,QSA,L]
Upvotes: 1
Reputation: 786091
You can use this rule in root .htaccess of server1:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^url=([^&]+) [NC]
RewriteRule ^pages/(.*)$ http://tracking.site2.com/s?key=123456789&url=%1 [QSA,NC,NE,R=301,L]
Fro back referencing captured group from RewriteCond
we need to use %1
, %2
etc instead of $1
, $2
.
Upvotes: 1