[英]Removing ?fbclid query string from the URL
我有以下 .htaccess 規則:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\/* index\.php?slug=$1
主要思想是捕獲鏈接並將它們發送到調度程序,如果某些 RegEx 規則適用,調度程序將調用 php 文件。 一切都發送到 index.php,它進行 RegEx 比較。 @CBroe,我嘗試匹配 URL 模式,然后 select 正確的 php 來調用,根據“規則”=> 的數組。 見下文。
補充:@iainn,這是一個古老的系統,靈感來自 WordPress 的“漂亮 URL”。 我現在不能簡單地重寫它,我不允許為此分配辦公時間。
例如:
$nodes = array(
'/posts\/(?P<slug>.+)(\/*)$/'=>'posts.php',
'/home(\/*)$/'=>'home.php',
)
在 Facebook 開始在 URL 末尾添加?fcbid 查詢字符串之前,一切正常。 補充:@CBroe,現在它只是匹配規則失敗,因為它們不期望查詢字符串。
補充:正如@Adam S.所建議的,一些有效的例子:
http://something.com/posts/1589285645-title-of-a-post
http://something.com/posts/1589285645-title-of-a-post/
http://something.com/home
http://something.com/home/
以下不起作用
http://something.com/posts/1589285645-title-of-a-post?fbclid=whatever
http://something.com/posts/1589285645-title-of-a-post/?fbclid=whatever
http://something.com/home?fbclid=whatever
http://something.com/home/?fbclid=whatever
我已經在這里嘗試了幾篇關於處理這個問題的建議,但這些都不適用於我的設置。
我應該如何重新格式化我的 .htaccess 文件來完成這個?
謝謝!
你可以試試這個規則:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?slug=$1 [L,QSA]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.