简体   繁体   English

从 URL 中删除?fbclid 查询字符串

[英]Removing ?fbclid query string from the URL

I have the following .htaccess rule:我有以下 .htaccess 规则:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\/* index\.php?slug=$1

The main idea is to capture links and send them to a dispatcher which, if certain RegEx rules apply, calls a php file.主要思想是捕获链接并将它们发送到调度程序,如果某些 RegEx 规则适用,调度程序将调用 php 文件。 Everything is sent to index.php, which does the RegEx comparison.一切都发送到 index.php,它进行 RegEx 比较。 @CBroe, I try to match a URL pattern, and then select the correct php to call, according to an array of 'rules'=>'scripts'. @CBroe,我尝试匹配 URL 模式,然后 select 正确的 php 来调用,根据“规则”=> 的数组。 See below.见下文。

Added: @iainn, it's an ages old system inspired in WordPress' "pretty URLs".补充:@iainn,这是一个古老的系统,灵感来自 WordPress 的“漂亮 URL”。 I can't simply rewrite it all at the moment, I'm not allowed to allocate office time for that.我现在不能简单地重写它,我不允许为此分配办公时间。

Eg:例如:

$nodes = array(
    '/posts\/(?P<slug>.+)(\/*)$/'=>'posts.php',
    '/home(\/*)$/'=>'home.php',
)

It's been alright until Facebook started adding the?fcbid querystring at the end of the URLs.在 Facebook 开始在 URL 末尾添加?fcbid 查询字符串之前,一切正常。 Added: @CBroe, now it just fails matching rules, because they don't expect a querystring.补充:@CBroe,现在它只是匹配规则失败,因为它们不期望查询字符串。

Added: as @Adam S. suggested, some examples that work:补充:正如@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/

And the following don't work以下不起作用

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

I've already tried several posts here with suggestions on dealing with this, but none of these apply to my setup.我已经在这里尝试了几篇关于处理这个问题的建议,但这些都不适用于我的设置。

How should I reformat my .htaccess file to accomplish this?我应该如何重新格式化我的 .htaccess 文件来完成这个?

Thanks!谢谢!

You may try this rule:你可以试试这个规则:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM