Forum Moderators: phranque

Message Too Old, No Replies

serving out /foo from a totally different location/server

mod_rewrite

         

jmichaels

7:23 pm on Sep 18, 2009 (gmt 0)

10+ Year Member



Hello, looking to see if this is possible in theory. I can probably work out the details, but before I deploy, now is the time to learn this.

example.com/blog
example.com/forums

versus

blog.example.com
forums.example.com

I would prefer to use the first example. I find that a cleaner method for an end user to understand. However, that puts the blog and forums in an area in which I have 100% custom code. I am dropping forums and a blog that are going to eventually have a security hole. If someone gets into blog or forums, it would not take a lot to ../ up a directory, and use php to read into my other files.

I would like to put the blog and forums elsewhere, in this case, on the same machine, but maybe down the road, on some other totally different machine.

Is my logic sound in that putting it in a different Apache directory block, with php's open_basedir set to that new directory, those would be much harder to get into my source files in example.com/ ?

If so, can mod_rewrite do what I am going to need this to do, which is going to be to essentially take all incoming requests for /blog/whatever-the-rest-is and somehow change that off to a blog.example.com/whatever-the-rest-is. I would still like blog.example.com to be completely inaccessible though. The url the user sees would never change, this is invisible to the user.

I do not think I want to use a proxy in Apache to do this, as does that not mean my stats would be totally useless, as they all appear to come from the same location?

Suggestions?

jdMorgan

2:26 pm on Sep 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want the request sent off to some other machine, then either link to that machine's (sub)domain or use mod_proxy with the options set on the originating server to send the X_Forwarded_For header, and the options set on the target machine to log the contents of that header instead of the REMOTE_ADDR variable.

Note that blog.example.com and www.example.com need not resolve to the same IP address in DNS; You're free to point any or all (sub)domains to different servers.

As for using blog.example.com versus example.com/blog, there are some issues, but it sounds like you've considered most of them.

Jim