如何在php中为重复的URL AB文本添加查询字符串


How to add query strings in php for duplicate URL AB text

现在我的工作使用PHP,它大约有20页。我需要复制所有的URL以及AB测试的查询字符串。

Original : www.lorem.com/index.php
Duplicate: www.lorem.com/index.php?custom (Something like that)

感谢团队

一个好的解决方案可以是在.htaccess文档中使用URL重写方案。像下面这样的解决方案可以工作:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/custom$ /$1-test.php [QSA,NC,L]
</IfModule>

这将导致以下情况成立:

Original  : www.lorem.com/index.php
Duplicate : www.lorem.com/index-test.php (When /custom is appended, this page is shown)

请查看以下内容,以供URL重写参考:https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/