我需要在 htaccess 文件中设置重写规则。我有以下 URL:
https://example.com/https%3A%2F%2Fwww.another.com%2Fcatalog%2F%3Fq%3Dhello+friend
我需要将其重定向到 URL 输出,如下所示:
https://newpage.com/3333333?url=https%3A%2F%2Fwww.another.com%2Fcatalog%2F%3Fq%3Dhello+friend
这https://example.com/将被取代https://newpage.com/3333333?url=。并且以下查询(无论什么)将在新链接中保持不变。
我尝试了很多次,但输出是https://newpage.com/3333333?url=https://www.another.com/catalog/catalog/?q=hello朋友:(
我的代码1:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com/?$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com/?$
RewriteRule (.*)$ https://newpage.com/3333333?url=$1 [R=302,L]
我的代码2:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com/?$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com/?$
RewriteRule (.*)$ https://newpage.com/3333333?url=%{REQUEST_URI} [R=302,L]
你能帮忙吗?提前致谢。