php - 从 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 开始在 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]
推荐阅读
- iot - Micropython 代码闪烁 ESP8266 的内置 LED 无效
- execution - 如何以访客身份远程执行 SMB 共享上的文件
- javascript - 确定按下哪个表格元素
- apache-spark - 如何在没有 kerberos 的情况下启动 spark 3.0.0 kubernetes 工作负载?
- spring-boot - spring 云流请求-回复
- python - 根据一列元素在熊猫上创建新列
- javascript - 在 React.js 中订阅 RxJS observable 的最佳方式
- python - Django,新用户注册时创建用户配置文件时出错
- flutter - PageController 总是给空闲作为结果 pageController.position.userScrollDirection
- javascript - React 组件在更新状态时重新渲染