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
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
.
如果要查询字符串,请像下面这样添加QSA(查询字符串追加)的附加标志:[R = 301,QSA,L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.