I have two questions.
First, I am in need of having a referral in my site. In PHP it would look like this: www.mysite.com/join?ref=100
and then on the page you would $_get(ref);
Zend does not like this, so how do I implement this.
The second question is how can I have a subdomain on my site with the framework. I want to put a forum on my site, and tried a subdomain and loaded it, but it will not work as Zend pushes everything through the index.php
. So how do I make it exist on the same site. I cannot put it in a module because it is a site within itself. Short of using another domain I am stuck.
Thanks for your help.
Getting GET parameters such as www.mysite.com/join?ref=100 should work normally. Assuming that join
is your controller and index
is your action in that controller that paratmeter ref
could be obtained using:
var_dump($_GET['ref']);
// or
var_dump($this->getRequest()->getParam('ref'));
So I don't see a reason why ZF would not like it.
Unfortunately I cannot help you with the second question, as I don't know.
For your second question about subdomains, there seem to be three issues:
- Network-level routing
- App-level routing
- Module structure
At the network level, you would configure your hosting environment so that all the subdomains point to a single folder in your hosting environment. Then deploy as standard ZF installation there, including the standard .htaccess
.
At the app level, your single ZF install will be receiving requests for all your subdomains. You can then use ZF's app-routing mechanism to handle those requests. In particular, you could configure various Zend_Controller_Router_Route_Hostname routes to handle the requests with your selected controllers/actions.
The last bit is which controllers and actions? It sounds like a good idea to create a separate module for each subdomain. So the Hostname routes above can detect the subdomain and handle the request with the appropriate module (and controller/action).
you should edit mod_rewrite rules in .htaccess
here is my rules:
RewriteEngine on
#do not rewrite for existing files and content of css, js, skin, forum subfolders
RewriteCond %{REQUEST_URI} ^/(css|js|skin|forum)/ [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*) - [L]
RewriteRule ^(.*)$ index.php [L]