重定向到家的路径,使用 .htaccess 将路径字符串作为 GET 变量

Redirect path to home, with path string as a GET variable using .htaccess

我正在尝试动态重定向表单的所有链接

example.com/path1
example.com/path2
example.com/path3
...

example.com?src=path1
example.com?src=path2
example.com?src=path3
...

静态规则如下

Redirect /path1 https://example.com?src=path1

但我想用 每个 可能的字符串来做到这一点。有什么想法吗?

能否请您尝试以下内容,根据显示的示例编写。请确保在测试 URL 之前清除浏览器缓存。

RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)/?$ ?src= [R=301,L]