Apache mod_rewrite - 如何从 url 隐藏 $_GET 变量

发布于 2024-09-17 08:40:25 字数 248 浏览 2 评论 0原文

当我调用页面时,

http://localhost/books-123-name.html?language_id=1

浏览器中会显示以下链接:

http://localhost/books-123-name.html

但会保留值 language_id=1

这该怎么办?

谢谢。

When I call the page

http://localhost/books-123-name.html?language_id=1

to appear in the browser the following link:

http://localhost/books-123-name.html

but will keep the value language_id=1

How can this be done?

Thanks.

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

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

发布评论

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

评论(3

醉殇 2024-09-24 08:40:25

除了 GET 参数之外,还有多种方法可以存储有关请求的信息。一种是使用 cookie,您可以将 language_id 存储在 cookie 中。使用 cookie 的一个特殊情况是使用会话。您还可以在 POST 请求中传递 language_id,因为 POST 参数对用户不可见。您还可以使用 mod_rewrite 仍然使用 GET 参数,但使它们更漂亮。

There are several ways to store information about requests other than GET parameters. One is using cookies, and you could store language_id in a cookie. A special case of using cookies would be using a session. You could also pass the language_id in a POST request, because POST parameters are invisible to the user. You might also use mod_rewrite to still use GET parameters, but make them prettier.

〗斷ホ乔殘χμё〖 2024-09-24 08:40:25

简而言之,你不能。

浏览器需要这些值才能读取它们。

您可以尝试读入它们,对它们执行某些操作,然后重定向到不带参数的页面。

或者使用POST

但更重要的是,为什么?

In short, you can't.

The browser needs those values there in order to read them.

You could try reading them in, doing something with them and then redirecting to a page without the parameters.

Or use POST.

But more importantly, why?

ぃ弥猫深巷。 2024-09-24 08:40:25

就像 jakenoble 所说的使用发布

或者也许你可以使用不同的 url 模式,例如

http://localhost/{人类可读语言}/books-123-name.html

例如http://localhost/en/books-123-name.html >

http://localhost/books-123-name.html?language_id={languade-id}

例如http://localhost/books-123-name.html?language_id=1< /代码>

Like jakenoble said use POST.

Or Maybe you can use a different url pattern like

http://localhost/{human-readable-language}/books-123-name.html

e.g. http://localhost/en/books-123-name.html

to

http://localhost/books-123-name.html?language_id={languade-id}

e.g. http://localhost/books-123-name.html?language_id=1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文