Tag Archives: Setup
I love pretty URLs. I don’t like file name extensions unless they end with .html.
All versions of symfony save me from address bar ugliness, but only for the first application I create. Everything else is ass.php/backwards.
I’m going to give you two ways of beautifying your second, third, and forth applications so you can http://www.get.your/application/looking/sexy. Both methods involve creating a subdirectory.
Put it all in a subdirectory, and symlink your way out
So if you have an app named “admin,” you can do the following:
- Create a directory in your web folder called admin
- Copy your admin.php and admin_dev.php into this folder
- Copy the .htaccess file into this folder
- Rename admin.php to index.php
- Edit the file now named index.php, and change the require_once statement at the top so it’s an extra directory back
- Symbolically link the js, css, images, and uploads directories from within the admin directory to the directory above; so from your app directory:
ln -s ../js
This is what I usually do in a Linux environment. However, I’m developing on a Windows box, and symbolic links don’t translate easily between Windows and Linux. So here’s the second option, without using symbolic links:
Put just the .htaccess in a subdirectory
- As before, create a subdirectory in your web folder for the admin.
- Copy the .htaccess file in, and at the very bottom of the file, change index.php to ../admin.php. It should read
RewriteRule ^(.*)$ ../admin.php [QSA,L]
- Edit your routing.yml file for the admin app, and append /admin/ to all of your routes.
That should about cover it. Also remember to set no_script_name to on in each of your applications.
Alternative methods? Please leave comments.