wordpress mod_rewrite 主题重定向

发布于 2024-09-18 14:41:27 字数 359 浏览 1 评论 0 原文

我有一个适用于 WordPress 3.0.1 的插件“主题我的登录”,它会导致我的用户个人资料页面位于此处:

domain.com/login-2?action=profile

而不是此处:

domain .com/profile

所以我尝试用 mod_rewrite 修复它,如下所示:

RewriteRule ^profile /login-2?action=profile

但它似乎什么也没做。我怀疑 WordPress 中发生了一些奇怪的事情,但在我进一步挖掘之前想问问这里的人们我的重写规则是否正确。我做对了吗?

I have a plugin "Theme My Login" for WordPress 3.0.1 which causes my user's profile pages to be here:

domain.com/login-2?action=profile

instead of here:

domain.com/profile

So I am trying to fix it with mod_rewrite like this:

RewriteRule ^profile /login-2?action=profile

But it seems to do nothing. I suspect it's some weird thing happening in WordPress but wanted to ask folks here if my rewrite rule looks correct before I dig further. Did I do it right?

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

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

发布评论

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

评论(1

浮世清欢 2024-09-25 14:41:28

默认情况下,我认为 WordPress 在路由请求时使用 REQUEST_URI 的值。您的规则

RewriteRule ^profile /login-2?action=profile

...应该正确地将 /profile 重写为 /login-2?action-profile,但 WordPress 不会观察到此更改,因为 $_SERVER 的值PHP中的[REQUEST_URI]是基于发送到服务器的原始请求。

可以通过让 WordPress 使用 PATH_INFO 来解决此问题,而不是通过修改默认的 WordPress 永久链接块来解决此问题:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php/$0

也可以使用 P 标志 用于代理重写的请求,这将更新 REQUEST_URI< /代码>。它带有创建新请求的开销,所以我不确定是否会推荐它:

RewriteRule ^profile /login-2?action=profile [P]

By default, I believe that WordPress uses the value of REQUEST_URI when routing the request. Your rule

RewriteRule ^profile /login-2?action=profile

...should correctly rewrite /profile to /login-2?action-profile, but WordPress will not observe this change because the value of $_SERVER[REQUEST_URI] in PHP is based on the original request send to the server.

It might be possible to work around this by getting WordPress to use PATH_INFO instead through modification of the default WordPress permalink block:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php/$0

It's also possible to use the P flag to proxy the rewritten request through, which will update the REQUEST_URI. It comes with the overhead of creating a new request, so I'm not sure if I'd recommend it:

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