mod_rewrite > /用户/tag1/tag2/tag..?page=1

发布于 2024-08-26 07:47:17 字数 503 浏览 2 评论 0原文

我正在尝试使用 mod_rewrite 来美化 URL。

我希望 URL 看起来像这样:

http://example.com/bart/school?page=2

重写的 URL 为:

http://localhost:8080/app?user=bart&tag1=school&page=2

如果可能,我还希望每个用户能够拥有多个标签:

http://example.com/bart/school/lisa?page=2

看起来像:

http://localhost:8080/app?user=bart&tag1=school&tag2=lisa&page=2

据我所知,通过使用这是可能的mod_rewrite 但我似乎无法弄清楚。任何帮助将非常感激!

I am trying to use mod_rewrite to pretty up a URL.

I want the URL to look like this:

http://example.com/bart/school?page=2

and the rewritten URL to be:

http://localhost:8080/app?user=bart&tag1=school&page=2

If possible, I would also like to be able to have more than one tag per user:

http://example.com/bart/school/lisa?page=2

Would look like:

http://localhost:8080/app?user=bart&tag1=school&tag2=lisa&page=2

I far as I can tell this is possible by using mod_rewrite but I can't seem to figure it out. Any help would be really appreciated!

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

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

发布评论

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

评论(1

疯了 2024-09-02 07:47:17

对于单个标签,请使用以下内容:

RewriteCond %{QUERY_STRING} ^page=([0-9]+)$
RewriteRule ^([^.]+)/([^.]+)$ http://localhost:8080/app?user=$1&tag1=$2&page=%1

For the single tag use the following:

RewriteCond %{QUERY_STRING} ^page=([0-9]+)$
RewriteRule ^([^.]+)/([^.]+)$ http://localhost:8080/app?user=$1&tag1=$2&page=%1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文