We help IT Professionals succeed at work.

htaccess 302 redirect - seamless hidden url

Mark Gilbert
Mark Gilbert asked

I have a base magento install on abc.com and have setup multi-sites and stores for different domain names.

If I setup xyz.com domain and set it as an alias to abc.com the site works as expected. Magento recognizes xyz.com in the address line and treats the site as if it were xyz.com. However, I cannot bind an SSL cert to this domain as it doesn't exist as an entity but as a pointer.
Therefore I'm under the understanding that for xyz.com to be served from abc.com and have xyz.com SSL cert I have to set it up as a site and use an htaccess file. I'm pretty familiar with htaccess files and have had many other setups work successfully simply using a 301 redirect. This though changes the address in the address bar. This is bad as magento will not know which site to serve up, so I figured a 302 redirect would work well.

I've done some extensive reading and from what I gather an external redirect such as xyz.com to abc.com would be would be defaulted to a 301 redirect.

How can I redirect to abc.com as xyz.com? I have full access to all the sites, with the only exception being that I cannot edit httpd.conf, hosts.conf or install new modules on the apache install.

FYI, I'm running the sites from RackSpace Cloud Sites offerings with a dedicated RackSpace Cloud Server for the database.

Please could some help.
Watch Question

I would probably try a slightly different route:
- have a real directory for the 2nd website, so that the ssl is working fine
- build symbolic links to all the directories under this one, so that although I seem to have 2 different and parallel tree structures... there is in fact only one
With this setup, you would not need extra redirect (although the redirects for magento's smart urls will still be needed)
Mark GilbertSenior Performance Engineer


Hi Fibo, thanks for your comment. You present a very interesting solution to this real nasty problem of mine and while I think it would work great in theory, there are 9070 files, and 3139 folders in the base install of magento. That's before any themes have been created. I may just have to go down the lines of uploading the base files to each secure.domainname.com site for the purposes of installing the SSL for each site on an as needed basis. Perhaps once I've presented all these findings we'll go down a centralized SSL cert site and have each site link to that for checkout.

I'll leave this question in place for the next day or so and then close but I do appreciate the time you took.

Have a great day.

The base install of Magent has <10 files and <10 directories on the top-level directory.

So you would have to
- create the directory
- copy the <10 files
- and, tyhe longer part, making the <10 symbolic links for the directories....

An almost unrelated remark: if you have ssh access, copying the whole file tree from within the unix shell would be 1 command and 30 seconds.
Mark GilbertSenior Performance Engineer


Fibo, thanks for the comment. Unfortunately I don't have access to ssh on cloud sites.

What I think I may have to do is setup a dedicated server with mod_proxy which will then redirect the sites to the master domain but masking the url with the required one. I will test that later on today and see what I can come up with. It's not the ideal solution as it means another server in the cluster but it may be the only way. Alternatively I will just need to come up with a batch script which could some how easily create a copy of the site using php. It's a tough situation but perseverance.

Thanks again.

Mark GilbertSenior Performance Engineer


Unfortunately due to system constraints it's not possible to follow all the recommendations made. These recommendations would work on most systems but not specific to the rackspace cloud sites offering. I'm accepting as the solutions provided are very useful for other scenarios as described.