Htaccess 子目录显示子域上的 WordPress
所以这里给你们做一个小测试:
在 sub.domain.com 安装了一个 Wordpress 博客
在 somewebsite.com 有一个网站
任何人都可以想出一种使用 .htaccess 的方法,以便以下是可能的:
- 你可以使用 wordpress 博客,就像它位于 somewebsite.com/blog/ 一样。
- wp-admin 可以通过 sub.domain.com/wp-admin 或 somewebsite.com/blog/wp-admin/ 访问,
- 无需进行重大更改Wordpress安装或模板。
期待看到您的想法。
So here is a little test for you guys:
There is a Wordpress blog installed at sub.domain.com
There is a website at somewebsite.com
Can anyone come up with a way to use .htaccess so that the following is possible:
- You can use the wordpress blog like it is located at somewebsite.com/blog/
- The wp-admin is accessible through sub.domain.com/wp-admin or somewebsite.com/blog/wp-admin/
- No major changes need to be made to the Wordpress install or templates.
Looking forward to seeing what you come up with.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.htaccess 重写非常简单(只需要一些正则表达式),但您将遇到的问题是 WordPress 本身。它真的不喜欢当你通过它的请求时它并不是真正期待的。作为回应,它只是将您重定向到对您想要前往的位置的最佳猜测。
即使使用可用于多域映射的少数插件之一,您仍然需要为每个博客分配一个主域。其他人只是重定向到那里。
因此,您的选择是(1)将一个重定向到另一个,或者(2)拥有两个由同一 WordPress 安装提供服务的独立博客。如果您希望其中一个重定向到另一个,您希望哪个是主要的?
The .htaccess rewrites would be pretty straightforward (just need some regex), but the problem you'll run into is within WordPress itself. It really doesn't like when you pass it requests it's not really expecting. In response, it just redirects you to its best guess as to where you were trying to go.
Even using one of the handful of plugins available for multiple-domain mapping, you still need to assign each blog one primary domain. The others just redirect there.
So your options are to either (1) have one redirect to the other or (2) have two separate blogs served by the same installation of WordPress. If you want one to redirect to the other, which would you prefer be the primary?