簡體   English   中英

如果 url 包含 fbclid 參數並刪除它,如何通過 htaccess 重定向到 https

[英]How redirect by htaccess to https if url containt fbclid parameter and remove it

fbclid=1 if url contain it <br> I'm using cloudflair 並且有問題

我現在的 htaccess

采樣器 url:

#sample: https://www.example.com/modules.php?name=News&file=article&sid=765766&fbclid=abcd#utm_source=iopio

RewriteCond %{QUERY_STRING} ^name=News&file=article&sid=(.*)&?fbclid=[^&]+&?(.*)$ [NC]
 #detect cloudflair if ssl set flexi. Web Server to cloudflare by http then cloudflair to browser by https
RewriteCond %{HTTP:Cdn-Loop} cloudflare [NC]
RewriteRule ^modules\.php$ https://%{HTTP_HOST}/modules.php?name=News&file=article&sid=%1%2 [R=302,L]

結果將重定向到

 https://www.example.com/modules.php?name=News&file=article&sid=#utm_source=iopio

它丟失了查詢%1
這里有什么問題??
肯定是:

https://www.example.com/modules.php?name=News&file=article&sid=765766&fbclid=abcd#utm_source=iopio

請指教
謝謝

您可以在站點根目錄 .htaccess 中使用此規則作為最重要的規則:

RewriteEngine On

RewriteCond %{HTTP:Cdn-Loop} cloudflare [NC]
RewriteCond %{QUERY_STRING} ^(.*&)?fbclid=[^&]*(?:&(.*))?$ [NC]
RewriteRule ^modules\.php$ https://%{HTTP_HOST}%{REQUEST_URI}?%1%2 [R=302,NE,L,NC]

測試后將302 (臨時重定向)改為301 (永久重定向)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM