Neu blog
Automatically switch Symfony front web controllers using .htaccess
Submitted by ryan on Mon, 21/07/2008 - 13:33
Ok here's a quick tutorial on how to enable application switching in Symfony with minimal fuss ... yes we love the sound of that!
Modify your .htaccess file
Edit your web/.htacces file and locate the lines that look like this:
# no, so we redirect to our front web controller RewriteRule ^(.*)$ index.php [QSA,L]
Duplicate the above and modify to your linking:
# no, so we redirect to our back web controller RewriteRule ^myadmin(.*)$ admin.php [QSA,L] # no, so we redirect to our front web controller RewriteRule ^(.*)$ index.php [QSA,L]
The ^myadmin(.*)$ is the URL so you should have no pages on your public application that start with this.
Update your routing.yml
Edit your backend/config/routing.yml file like so:
homepage:
url: /myadmin
param: { module: default, action: list }
default_symfony:
url: /symfony/:action/*
param: { module: default }
default_index:
url: /myadmin/:module
param: { action: index }
default:
url: /myadmin/:module/:action/*CONTACT US
- 1300 858 495
- +61 2 8011 8238
- Suite 202, 8 Clarke street Crows Nest, NSW 2065, Australia
- View Google map
Web design
Engaging websites and digital experiences that deliver ease of use with fresh, contemporary design.
Web development
Custom built PHP business applications including CMS, CRM, customer databases and third-party software integration.
Web marketing
Exposing business to a global audience through SEO, adwords, email marketing and banner advertising.