正在删除?来自URL的fbclid查询字符串



我有以下.htaccess规则:

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

其主要思想是捕获链接并将其发送到调度器,如果适用某些RegEx规则,则调度器会调用php文件。所有内容都被发送到index.php,后者进行RegEx比较@CBroe,我尝试匹配一个URL模式,然后根据一组"规则"=>"脚本"选择正确的php进行调用。请参见下文

添加:@iainn,这是一个受WordPress"漂亮URL"启发的古老系统。我现在不能简单地重写它,我不允许为此分配办公时间

例如:

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

在Facebook开始添加之前一切都很好?fcbid querystring位于URL末尾添加:@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]

最新更新