I have a ZF website at domainA.com and I’d like to alias domainB.com to something like: domainA.com/photos/album so that album would be the root of domainB.
How might this be accomplished?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The first step here is to rewrite the URL to the correct route using
mod_rewrite. Something like the following at the top of your exisitng.htaccessroot should work:This will redirect to
/photos/album/if no path is specified afterdomainB.com. If I remember correctly, Zend Framework isn’t picky about whether your controllers/actions are terminated by a slash or not, so this should be fine. If it needs to be/photos/albumfor some reason, I have a solution for that as well, but it’s overkill if it’s not needed.Later, your ruleset translates the URL to
index.php, and Zend Framework does its routing. However, the default way Zend Framework does routing is to useREQUEST_URI, which happens to not be what we want in this case (It will be whatever was passed afterdomainB.com, instead of what we rewrote the request to). We actually need to useREDIRECT_URL, which is set by our newRewriteRule.The controller request documentation describes this scenario (kind of), and explains that you can use
Zend_Controller_Request_Apache404as a drop-in request object to obtain the correct route information:I’m fairly certain that you could also just get the current request object, and call
on it. Just condition this operation on the host, and hopefully it should all work out correctly.