Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm currently working on a site that's hosted across two different servers. One server hosts the main site (example.co.uk), the other server hosts an ecommerce application (Magento) and is currently accessible at shop.example.co.uk.

I have full access to the server hosting the ecommerce site, and full access to the domain configuration; however the main site is hosted on shared hosting and the only access I have is through FTP.

Without moving the ecommerce application over to the shared hosting, is there any way in this setup that we could have the ecommerce site accessible via example.co.uk/shop and only this URL? We only want access to be from the subdirectory (for SEO reasons), so entering the shop.example.co.uk domain should redirect to example.co.uk/shop.

I'm currently trying to ascertain whether mod_proxy is available on the shared host, though it seems unlikely. Would that be the only way to do this?

EDIT: Thanks for all the answers so far. To explain the rationale a little, this is for a client, who wishes to host the main site himself, as it is developed and managed by a separate company.

share|improve this question

4 Answers 4

up vote 1 down vote accepted

mod_proxy is indeed the most viable solution that I can think of at the moment if you want to keep those sites physically separated. Basically its a textbook example for RewriteRule's [P] flag:

Given Rule                                      Resulting Substitution
----------------------------------------------  ----------------------------------
^/somepath(.*) http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfo
                                                via internal proxy

As Richard mentioned, by merging those two sites physically together you can avoid creating unnecessary problems on the way, and in this case it would probably serve better in the long run.

Though some weird idea I had - if mod_proxy support is a problem, and you can't do anything about it on your shared hosts, then why not switch the roles?

Let's make your ecommerce server the main server serving all the content under example.co.uk via a proxy to your shared host (now using some other dummy domain name - like site.example.co.uk) and example.co.uk/shop directly. Then redirect all non-proxy traffic hitting site.example.co.uk to example.co.uk.

The question remains though - why do it in the first place? If you're going as far as this, then just moving all the site to the the ecommerce server would be most reasonable. Especially in the case when you may be hitting some resource constraints on the ecommerce server. Plus adding some latency to proxy all this seems really unnecessary. The only situation I can think of where this would be useful is if you have some very dedicated environment/toolchain set on your shared host that is hard to replicate on your current ecommerce server. But, to be honest, I doubt that's the case.

Please elaborate a bit more on what's your rationale for keeping those sites separate. Maybe we can find some better solution addressing your underlying needs.

share|improve this answer
    
I hadn't actually thought of the reverse proxy idea, but it seems like a rather clever solution to the problem (given that the main site must continue to be hosted in a shared environment, outside of our direct control.) –  Manacora Apr 6 '11 at 13:27
    
In that case it should work. Though I think it's not a very elegant and fail-proof solution, so you should weigh the consequences of such a setup in comparison to staying with a separate ecommerce subdomain. –  Karol Piczak Apr 6 '11 at 13:34

if your prepared to go through the pain of modifying your magento install then yes you can do this

you will have to go through the magento config/database and update any reference of shop.example.com to example.com/shop (you will have to do this if you want to use 301 redirects from shop.example.com)

that way you can then move it into the subdirectory and then move your main site into the main directory and import all that site in (you will have to do this if you cant o reverse proxy which i doubt a shared host will do for you)

once thats all done you can just create a standard 301 redirect of shop.example.com to example.com/shop

also dont forget unless you have a wildcard ssl or an ssl for both the domain and subdomain your going to need a new ssl certificate

share|improve this answer

Unfortunately there's no easy way to achieve this, the domain.com/shop method assumes that /shop is a local folder and not a remote folder. You could use a number of .htaccess methods to redirect clients, or to mask the URL but this would most likely cause more problems for you in terms of search engine optomisation. Is there a particular reason you can't merge the two servers together to use the desired URL format?

If the two servers are within the same network, you could consider an iscsi/nfs connection between them both, allowing the remote folder to become the 'local' folder (symbolic link).

share|improve this answer

If you do have mod_proxy available on your shared hosting, along with mod_rewrite you can use something like:

RewriteEngine On
RewriteRule ^shop/(.*)$ http://shop.example.co.uk/$1 [P]

[P] being the proxy flag that requires mod_proxy, which should allow your ecommerce site function as-is (I'm not familiar with Magento) as the Requests that are getting that server should be the same as before.

However, this doesn't prevent access http://shop.example.co.uk directly, which you would probably want to address as well.

Hopefully this helps.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.