admin管理员组文章数量:1122846
I am interested in having a blog on my site which will be in a subdirectory of the main wordpress homepage
e.g. website/blog
however, I am interested to know if there is a way to host the blog on a separate server - primarily because I don't want to overload the server for the rest of the site if there is a lot of traffic going to the blog. I am keen on the idea of it being a subdirectory though.
Anyway - just thought there would be someone smarter than me who might have a bright idea :)
I am interested in having a blog on my site which will be in a subdirectory of the main wordpress homepage
e.g. website.com/blog
however, I am interested to know if there is a way to host the blog on a separate server - primarily because I don't want to overload the server for the rest of the site if there is a lot of traffic going to the blog. I am keen on the idea of it being a subdirectory though.
Anyway - just thought there would be someone smarter than me who might have a bright idea :)
Share Improve this question edited Jul 23, 2014 at 16:36 Joji Mori asked Jul 23, 2014 at 16:23 Joji MoriJoji Mori 1111 gold badge1 silver badge4 bronze badges 2- 1 so you want two separate wordpress installations hosted on two separate servers but you want the URLs for website.com/blog to redirect to wherever the other site is hosted? Depending on your host that should be possible and there would be more than one way of doing it, but it isn't really a wordpress question at that point since each wordpress installation would be rather straightforward. – KnightHawk0811 Commented Jul 23, 2014 at 16:49
- 1 You can have multiple servers but with the same content, so when one server fails, the content is taken from the other server. It is possible balance loading hardware, that is what determines which server will respond to the requests. But I'm not sure if it's possible with different content. – Unix Commented Jul 23, 2014 at 17:01
4 Answers
Reset to default 7A reverse proxy could work, such as varnish or nginx. Using varnish as an example:
backend blog {
.host = "blog-server-ip";
}
backend default {
.host = "current-domain-ip";
}
sub vcl_recv {
if (req.rul ~ "^/blog/") {
req.backend = blog;
}
}
There are multiple additional approaches available today:
- DIY with Cloudflare Workers: https://shapo.io/blog/wordpress-blog-on-a-subdirectory-with-cloudflare/
- Consulting service for CloudFlare Workers: https://slashblog.co/
- Paid proxy (general, for your entire site): https://hostforward.io/
- Paid proxy (WordPress specific, just for
blog/
): https://pressproxy.io/
A better way to to do this is to instead of a subdirectory, use a subdomain like blog.website.com
. The reason for this is that a DNS record can be made to the other server for the subdomain, which is not possible with subdirectories.
A subdirectory is possible, but you would have to use frames, a .htaccess
redirect or another way which is totally not stable in a production environment.
If you want to use a subdirectory like example.com/blog
, the best way (and it's not a good way...) is to use an .htaccess
file. You can make a redirect like this: Redirect 301 <server IP>
where server IP stands for the IP address of the server you want to host your blog on. Note that the user will see the IP address in the address bar which is not recommendable.
Therefore, you might also want to give frames a try. Use iFrames, frames are outdated and no-one will recommend to use them. Note that iFrames or frames aren't a good solution either, but if you really want to use a subdirectory this is what you'll have to do... create an index file (e.g. website.com/blog
), and place <iframe src="<server IP>"></iframe>
there.
Note that also this is no good solution and I really recommend using a subdomain.
If you want to use a subdomain like blog.website.com
, go to a place where you can manage your domain's DNS and add a an A record which points to the IP of the server you are going to host your blog on.
Edit: this is off-topic, but worth mentioning: if you don't want an overload on your server, instead of having multiple servers, you can set up cluster hosting. This is a very handy technique, especially for websites that have many traffic. The concept is to spread the load of hosting across multiple servers. Here's the Wikipedia article about clustered hosting - I recommend reading it. There are multiple hosting providers that offer cluster hosting. Unfortunately I only know Dutch hosting providers that offer clustered hosting, so I can't recommend one. The cheapest I know in The Netherlands is about €100,- per year, so clustered hosting is quite affordable.
Good luck!
Does it have to be website.com/blog?
A faster solution and less complex would be to just host the blog as blog.website.com
For website.com/blog, your best solution is to employ URL Redirects..
see:
https://serverfault.com/questions/567476/permanently-redirect-subfolder-blog-to-subdomain-on-another-server
本文标签: Can you have a blog in a subdirectory hosted on a different server
版权声明:本文标题:Can you have a blog in a subdirectory hosted on a different server? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736301772a1931293.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论