通过 mod_rewrite 重定向并重写 URL

发布于 2025-01-01 02:38:06 字数 569 浏览 3 评论 0原文

我的锚点是这样的

<a href="http://localhost/haveg/employer?id=7003&title=the-message-title">employer</a>

当我单击锚点时,我想到达这里,

http://localhost/haveg/employer/7003/the-message-title

到目前为止,我已经编写了这个 .htacess 代码

Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteBase /
RewriteRule ^haveg/employer/([0-9]+)/?(.*) haveg/employer.php?id=$1

,该代码仅在我输入 http://localhost/haveg/employer/7003/the- 时打开页面message-title 但我想在单击锚点后到达这里。

谢谢。

My anchor is like this

<a href="http://localhost/haveg/employer?id=7003&title=the-message-title">employer</a>

And when i click the anchor i want to reach here

http://localhost/haveg/employer/7003/the-message-title

so far i have written this .htacess code

Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteBase /
RewriteRule ^haveg/employer/([0-9]+)/?(.*) haveg/employer.php?id=$1

which only opens the page when i type http://localhost/haveg/employer/7003/the-message-title but i want to reach here after i click the anchor.

thanks.

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

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

发布评论

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

评论(3

维持三分热 2025-01-08 02:38:06

我认为这就是你想要的:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^haveg/employer/([0-9]+){1,5}/?(.*) haveg/employer.php?id=$1&title=$2 [L,NC]

你的锚点必须像这样构建:

<a href="/haveg/employer/7003/the-message-title">employer</a>

I think this is what you want:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^haveg/employer/([0-9]+){1,5}/?(.*) haveg/employer.php?id=$1&title=$2 [L,NC]

Your anchor would have to be built like:

<a href="/haveg/employer/7003/the-message-title">employer</a>
眼眸里的快感 2025-01-08 02:38:06

Mod 重写不会重定向您必须放置的链接
http://localhost/haveg/employer/7003/the-message-title
在你的锚中,mod rewrite 所做的就是加载
http://localhost/haveg/employer?id=7003&title=the -消息标题
在后台并显示它

Mod rewrite doesn't redirect links you have to put
http://localhost/haveg/employer/7003/the-message-title
in your anchor what mod rewrite does is it will load
http://localhost/haveg/employer?id=7003&title=the-message-title
in the background and display it

瑶笙 2025-01-08 02:38:06
RewriteCond %{QUERY_STRING} ^id=([^&]*)\&title=([^&]*)$
RewriteRule ^index.php /employer/%1/%2? [L,R=301]
RewriteCond %{QUERY_STRING} ^id=([^&]*)\&title=([^&]*)$
RewriteRule ^index.php /employer/%1/%2? [L,R=301]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文