Question

We are putting up a company blog at companyname.com/blog but for now the blog is a Wordpress installation that lives on a different server (blog.companyname.com).

The intention is to have the blog and web site both on the same server in a month or two, but that leaves a problem in the interim.

At the moment I am using mod_rewrite to do the following:

http://companyname.com/blog/article-name redirects to http://blog.companyname.com/article-name

Can I somehow keep the address bar displaying companyname.com/blog even though the content is coming from the latter blog.companyname.com?

I can see how to do this if it is on the same server and vhost, but not across a different server?

Thanks

Was it helpful?

Solution

Rather than using mod_rewrite, you could use mod_proxy to set up a reverse proxy on companyname.com, so that requests to http://companyname.com/blog/article-name are proxied (rather than redirected) to http://blog.companyname.com/article-name.

Here are more instructions and examples.

OTHER TIPS

There is functionality with ZoneEdit called webforwards which could probably do this and hide what you are actually doing (unless someone looked into it).

The only thing that mod_rewrite can do is send HTTP header redirects, and those redirects (across servers) always result in the browser address bar reflecting the reality.

You should instead consider writing a 404 script that 'reflects' the blog. This would essentially be a transparent proxy, and many are already written.

The script would find if the requested page (that was 404'd) started with http://mycompany.com/blog/ . If it did, it would download and then send onto the client the blog page and associated files (probably caching them as well).

So requesting http://mycompany.com/blog/article_xyz would cause the 404 script to download and send http://blog.companyname.com/article_xyz.

It's probably more work than it's worth, but you might be able to design a simple enough 404 script that it's worthwhile.

-Adam

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top