views:

91

answers:

2

Symfony uses the following typical .htaccess file:

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

and I have this as my vhost:

<VirtualHost 127.0.0.1:80>
    ServerName jobeet.loc
    DocumentRoot "C:/wamp/www/jobeet/web"
    DirectoryIndex index.php
<Directory "C:/wamp/www/jobeet/web">
    AllowOverride All
    Allow from All
</Directory>

Alias /sf "C:/wamp/lib/symfony-1.4.1/data/web/sf"
<Directory "C:/wamp/lib/symfony-1.4.1/data/web/sf">
    AllowOverride All
    Allow from All
</Directory>

The above works perfectly, but I want to know how to map and additional debugging url, http://jobeet.dev to automatically serve the frontend_dev.php file so I can use urls like:
http://jobeet.dev/jobs/...
instead of
http://jobeet.dev/frontend_dev.php/jobs/... to map to the debug .php file in the framework.

I tried adding a duplicate of the vhost entry and simply changing the servername and directoryindex to
ServerName jobeet.dev
DirectoryIndex frontend_dev.php
but understandably this does not work, as I believe I would need to check the URL in the .htaccess to do this?

Can anyone offer some advice regarding this?

Thanks in advance! :)

A: 

I'd recommend you to map all needed hosts (jobeet.loc, jobeet.dev, etc) to SF_DIR/web, set index.php as dir-index (as you did) and in that file just run particular app with a particular env depending on $_SERVER['HTTP_HOST'].

Hope I described good to make an idea clear.

Darmen
+2  A: 

First add jobeet.dev as a ServerAlias in your current VirtualHost so it can share the same hosting configuration:

<VirtualHost 127.0.0.1:80>
    ServerName jobeet.loc
    ServerAlias jobeet.dev
    DocumentRoot "C:/wamp/www/jobeet/web"
    ....

Don't forget to restart Apache when you're done.

Next, turn on no_script_name in your dev configuration in apps/frontend/config/settings.yml:

dev:
  .settings:
    no_script_name: true

Now your dev web controller (frontend_dev.php) won't show up in your auto-generated URLs (from link_to(), url_for(), etc).

Finally, set up a RewriteRule for your dev domain before your production controller comes in to play to route everything coming in at jobeet.dev to your dev web controller:

  RewriteEngine on
  ...
  ...
  RewriteCond %{HOST_NAME} ^jobeet\.dev$
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ frontend_dev.php [QSA,L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php [QSA,L]

That should do it.

Cryo