wordpress mod_rewrite 主题重定向
我有一个适用于 WordPress 3.0.1 的插件“主题我的登录”,它会导致我的用户个人资料页面位于此处:
domain.com/login-2?action=profile
而不是此处:
domain .com/profile
所以我尝试用 mod_rewrite 修复它,如下所示:
RewriteRule ^profile /login-2?action=profile
但它似乎什么也没做。我怀疑 WordPress 中发生了一些奇怪的事情,但在我进一步挖掘之前想问问这里的人们我的重写规则是否正确。我做对了吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,我认为 WordPress 在路由请求时使用
REQUEST_URI
的值。您的规则...应该正确地将
/profile
重写为/login-2?action-profile
,但 WordPress 不会观察到此更改,因为$_SERVER 的值PHP中的[REQUEST_URI]
是基于发送到服务器的原始请求。可以通过让 WordPress 使用
PATH_INFO
来解决此问题,而不是通过修改默认的 WordPress 永久链接块来解决此问题:也可以使用
P
标志 用于代理重写的请求,这将更新REQUEST_URI< /代码>。它带有创建新请求的开销,所以我不确定是否会推荐它:
By default, I believe that WordPress uses the value of
REQUEST_URI
when routing the request. Your rule...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:It's also possible to use the
P
flag to proxy the rewritten request through, which will update theREQUEST_URI
. It comes with the overhead of creating a new request, so I'm not sure if I'd recommend it: