Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

As I'm using url rewriting to access my Symfony2 application, it is directly available from

Now I'd like to be able to access the dev environment simply using a different port like:
share|improve this question

1 Answer 1

If you don't want to use

That does pretty much the same job, here the solution:

After having allowed your external IP to my_application/web/app_dev.php

// ...
if (isset($_SERVER['HTTP_CLIENT_IP'])
    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
    || !in_array(@$_SERVER['REMOTE_ADDR'], array(
        '', // <- your IP
        // ...
) {
// ...

Configured /etc/apache2/ports.conf to tell Apache to listen in the additional port

NameVirtualHost *:80
Listen 80
NameVirtualHost *:8081
Listen 8081

Simply duplicate the applications vhost (if you are using one)

$ sudo cp /etc/apache2/sites-available/my_application \

and change the file pointed by the url rewriter

<VirtualHost *:8081>

    DocumentRoot "/var/www/my_application/web"
    <Directory "/var/www/my_application/web/">
        <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ /app_dev.php [QSA,L]

Finally activate the new vhost

$ sudo a2ensite my_application_dev
$ sudo service apache2 restart
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.