.htaccess从路径末端重写规则

发布于 2025-01-25 03:06:39 字数 387 浏览 4 评论 0原文

我需要根据以下模式重写我的URL规则:

启动URL:

https://example.com/path/&ppath/¶m1=1¶m2=2

tastion>目标url:

httpps ://example.com/file.php?param1 = 1& param2 = 2

i因此,我需要获取& amp;特点。

我知道它形成的启动URL和那是吗?需要,但是不幸的是,我有这种模式可遵循。 我尝试了这个,但我无法获得&特点。

重写 ^路径([&])$ file.php?$ 1 [l]

您有什么想法吗?

I need to rewrite the rule for my url according to this pattern:

Starting url :

https://example.com/path/¶m1=1¶m2=2

Destination url:

https://example.com/file.php?param1=1¶m2=2

I therefore need to get everything that comes after the & character.

I know it's poorly formed the starting url and that the ? would be needed, but unfortunately I have this pattern to follow.
I tried this but I can't get the & character.

RewriteRule ^path([&])$ file.php?$1 [L]

Do you have any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花之痕靓丽 2025-02-01 03:06:39

使用您显示的样本,请尝试遵循HTACCESS规则文件。这确实是内部重写到file.php并将查询字符串发送为param1 = 1& param2 = 2在后端中。

还要确保您的file.php和.htaccess规则文件处于同一路径。在测试URL之前,请确保清除浏览器缓存。

RewriteEngine ON
RewriteCond %{THE_REQUEST} \s/[^&]*&(\S+) [NC]
RewriteRule ^ file.php?%1 [QSA,L]

With your shown samples, attempts please try following htaccess rules file. This does internal rewrite to file.php and sends query string as param1=1¶m2=2 in backend.

Also make sure your file.php and .htaccess rules file are in same path. Make sure to clear your browser cache before testing your URLs.

RewriteEngine ON
RewriteCond %{THE_REQUEST} \s/[^&]*&(\S+) [NC]
RewriteRule ^ file.php?%1 [QSA,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文