动态 URL 重定向

发布于 2024-10-15 21:21:19 字数 172 浏览 4 评论 0原文

如何将我的网址 - www.example.com/home.php?rid=888601032 重定向

到 www.example.com/examplepage.php

我已经尝试了几个 htaccess 代码 7 我是 htaccess 的新手,如果有人能给我,我将不胜感激正确的重定向代码。

How to redirect my url - www.example.com/home.php?rid=888601032

to www.example.com/examplepage.php

i have tried several htaccess codes 7 Im new to htccess, I would appreciate if someone can give me the correct redirect code.

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

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

发布评论

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

评论(4

从﹋此江山别 2024-10-22 21:21:19

您需要的重定向非常简单。

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(home\.php)?\?rid=888601032\ HTTP/
RewriteRule ^(home\.php)?$ http://www.example.com/examplepage.php? [R=301,L]

它会重定向任何带有 RID 的根请求。

The redirect you need is incredibly simple.

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(home\.php)?\?rid=888601032\ HTTP/
RewriteRule ^(home\.php)?$ http://www.example.com/examplepage.php? [R=301,L]

It redirects any root request with the RID within it.

心如荒岛 2024-10-22 21:21:19

语法为:

redirect accessed-file URL-to-go-to

有 3 部分;

(1) the Redirect command,
(2) the location of the file/directory you want redirected, and
(3) the full URL of the location you want that request sent to.

这些部分由一个空格分隔,并且应该在一行上。

例如,如果您想将用户从您帐户 myaccount 的 www 目录中的 oldfile.html 重定向到 newpage.html,则语法应为

redirect /~myaccount/oldfile.html http://www.indiana.edu/~myaccount/newpage.html

The syntax is:

redirect accessed-file URL-to-go-to

There are 3 parts;

(1) the Redirect command,
(2) the location of the file/directory you want redirected, and
(3) the full URL of the location you want that request sent to.

These parts are separated by a single space and should be on one line.

For example, if you want to redirect users from oldfile.html in the www directory of your account, myaccount, to newpage.html, the syntax should be

redirect /~myaccount/oldfile.html http://www.indiana.edu/~myaccount/newpage.html
千年*琉璃梦 2024-10-22 21:21:19

将其放入 .htaccess 文件中:

RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} rid=888601032
RewriteRule ^home.php       examplepage.php [R,L,QSA]

如果您不希望重定向可见,请保留 [R] 标志。

希望这有帮助!

Put this in yout .htaccess file:

RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} rid=888601032
RewriteRule ^home.php       examplepage.php [R,L,QSA]

If you dont want the redirect to be visible, leave the [R] flag.

Hope this helps!

病女 2024-10-22 21:21:19

使用 php 来做这件事不是更好吗?

if ((int)$_GET['rid'] == 888601032) // or something like this
    header('Location: examplepage.php');

这取决于你想要做什么,但是如果你想根据“rid”参数重定向到不同的页面,或者如果你想在重定向用户之前执行一些操作(例如设置cookie),那么它会更灵活。

Wouldn't be better to use php to do this?

if ((int)$_GET['rid'] == 888601032) // or something like this
    header('Location: examplepage.php');

It depends on what you want to do, but it would be more flexible if you want to redirect to a different page depending on the "rid" parameter, or if you want to do some operation (like setting a cookie) before redirecting the user.

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