使用 .htaccess 将标准请求 Uri 转换为干净的 URL

发布于 2024-09-27 03:04:25 字数 787 浏览 1 评论 0原文

我的 URL 格式如下:

http://domain .com/checkout/nonce/701fe0f652/order/108/?token=EC-0DS37792JX3680821

我尝试使用 .htaccess 将其转换为干净的 URL:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?token=(.*)$ /index.php/$1/token/$2/ [R]

RewriteRule 不知何故不起作用。我已经使用 http://jakarta.apache.org/regexp/applet.html 并产生精确匹配。

我正在使用 CodeIgniter,并且已经测试直接放置干净的 URL (http://domain.com/checkout/nonce/701fe0f652/order/108/token/EC-0DS37792JX3680821) 没有问题。

有人可以帮助我吗?

谢谢。

此致。

I have a URL with the following format:

http://domain.com/checkout/nonce/701fe0f652/order/108/?token=EC-0DS37792JX3680821

I try to convert it into a clean URL using .htaccess:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?token=(.*)$ /index.php/$1/token/$2/ [R]

The RewriteRule somehow does not work. I already test that using http://jakarta.apache.org/regexp/applet.html and resulting exact matches.

I'm using CodeIgniter, and already test to put the clean URL (http://domain.com/checkout/nonce/701fe0f652/order/108/token/EC-0DS37792JX3680821) directly with no problem.

Can somebody help me?

Thank you.

Best regards.

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

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

发布评论

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

评论(1

剑心龙吟 2024-10-04 03:04:25

我已经找到了答案

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^token=([a-zA-Z0-9\-]+)
RewriteRule ^([a-z0-9\/\-.]+)$ $1token/%1? [R=301,L]

I have found the answer for it

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^token=([a-zA-Z0-9\-]+)
RewriteRule ^([a-z0-9\/\-.]+)$ $1token/%1? [R=301,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文