URL 传递变量时的组合

URL composition when passing variables

如何将变量传递到另一个带有 URL 的页面,如下所示?

www.domain.com/results?search_query=test

而不是像这样:

www.domain.com/results/?search_query=test

(指"results"后的斜杠)

我认为第一个 URL 看起来更好,但每次我尝试在我的网站上使用它时,它都会自动插入一个斜杠。

目前,我的文件路径看起来像这样root>results>index.php(我将变量传递到的文件)

不要创建一个名为 results 的文件夹,其中包含 index.php,而是在根目录中创建一个名为 results.php 的 php 文件。

然后使用 .htaccesss 文件,您可以重写 link 以适应您的需要。

RewriteEngine on
RewriteRule ^([^/]*)$ .php