<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://www.symforc.com/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>Symfony Resources Central - controller</title>
  <link>http://www.symforc.com/</link>
  <description>A place that groups many original symfony resources, along with my personal experiments of this great PHP5 MVC framework.</description>
  <language>en</language>
  <pubDate>Sat, 26 Jul 2008 19:34:33 +0200</pubDate>
  <copyright>All rights reserved</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>A new index.php controller for subdomains</title>
    <link>http://www.symforc.com/post/2007/06/28/A-new-indexphp-controller-for-subdomains</link>
    <guid isPermaLink="false">urn:md5:9363e9772236cc82a7a7af275b06db7f</guid>
    <pubDate>Sun, 21 Oct 2007 23:24:00 +0200</pubDate>
    <dc:creator>Romain</dc:creator>
        <category>hacks</category>
        <category>controller</category><category>dns</category><category>hacking</category><category>php</category><category>url</category>    
    <description>&lt;p&gt;The default behaviour of symfony, is to create one myapp.php and one myapp_dev.php public controller by application, knowing that the first application you create will have its prod controller renamed to index.php (default application). But this behaviour can be easily overriden to take advantage of subdomains.&lt;/p&gt;    &lt;p&gt;Here is a little file replacing every public controllers of symfony by an unique index.php, to select the application and environment depending on current subdomain (you can even change it to select depending of the domain though). The aim is to get your different applications on the following domain names:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;http://blog.example.com&lt;/li&gt;
&lt;li&gt;http://blog-dev.example.com&lt;/li&gt;
&lt;li&gt;http://forum.example.com&lt;/li&gt;
&lt;li&gt;http://forum-dev.example.com&lt;/li&gt;
&lt;li&gt;http://www.example.com&lt;/li&gt;
&lt;li&gt;http://www-dev.example.com&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The *-dev domains are the development environment version of their matching non-dev subdomains, and thoose will only be available from authorized IPs, to avoid exposing too much information to the public. You only need to get the source given at the bottom of this article and substitute %project_dir%/web/*.php by this unique index.php, then customize it to fit your applications name and your subdomains.&lt;/p&gt;


&lt;p&gt;Note that in this example, i have a fallback 'website' app for non existing subdomains, that pass the current subdomain to it through the SF_SUBDOMAIN constant. Using this, you could for example give a homepage to each of your users, or create a white label site for each of your clients... Possibilities are just limited by your imagination.&lt;/p&gt;


&lt;p&gt;Related links:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://hashbin.com/V0&quot; hreflang=&quot;php&quot;&gt;index.php source code&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
    
    
    
          <comments>http://www.symforc.com/post/2007/06/28/A-new-indexphp-controller-for-subdomains#comment-form</comments>
      <wfw:comment>http://www.symforc.com/post/2007/06/28/A-new-indexphp-controller-for-subdomains#comment-form</wfw:comment>
      <wfw:commentRss>http://www.symforc.com/feed/rss2/comments/51</wfw:commentRss>
      </item>
    
</channel>
</rss>