1

I would like to change my url using only .htaccess, how can i change my url from this : http://s1rd-ubuntu-01/vpscraplist/web/app_dev.php/myproject/ to this http://vpscraplist/platform/ or this http://vpscraplist/

i have also more pages on my project as http://s1rd-ubuntu-01/vpscraplist/web/app_dev.php/myproject/add and http://s1rd-ubuntu-01/vpscraplist/web/app_dev.php/myproject/edit ...

I've already used thoses scripte but not work for me :(

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On

# Explicitly disable rewriting for front controllers
RewriteRule ^app_dev.php - [L]
RewriteRule ^app.php - [L]

RewriteCond %{REQUEST_FILENAME} !-f

# Change below before deploying to production
#RewriteRule ^(.*)$ /app.php [QSA,L]
RewriteRule ^(.*)$ /app_dev.php [QSA,L]

or this one :

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On

# Explicitly disable rewriting for front controllers
RewriteRule ^/web/app_dev.php - [L]
RewriteRule ^/web/app.php - [L]

# Fix the bundles folder
RewriteRule ^bundles/(.*)$ /web/bundles/$1  [QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f
# Change below before deploying to production
#RewriteRule ^(.*)$ /web/app.php [QSA,L]
RewriteRule ^(.*)$ /web/app_dev.php [QSA,L]

Thank you and sorry about my english !

1 Answers1

0

In my opinion the best approach is to keep the default htaccess of symfony, and to configure your apache vhost as explained there: http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html

(don't forget to enable the apache rewrite if it is not dude: sudo a2enmod rewrite )

create the vhost file:

sudo nano /etc/apache2/sites-available/yoursite.conf

with:

<VirtualHost *:80>
    ServerName mydomain.net
    ServerAlias www.mydomain.net

    DocumentRoot /var/www/myprojectSymfony/web
    <Directory /var/www/myprojectSymfony/web>
        AllowOverride All
        Order Allow,Deny
        Allow from All
    </Directory>

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>


    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>

Once you have have created your virtual file, you must enable them

sudo a2ensite yoursite.conf

When you are finished, you need to restart Apache to make these changes take effect:

sudo service apache2 restart
goto
  • 7,908
  • 10
  • 48
  • 58
  • Thanks for the answer, ive done this like this: ` ServerAdmin webmaster@localhost ServerName myproject.vpccpp.fr ServerAlias www.myproject.vpccpp.fr DocumentRoot /var/www/html/myproject/web AllowOverride All Order Allow,Deny Allow from All ` ... but nothing change, do i have to do some command line before or after to get work? – user3590036 Jul 01 '16 at 14:00
  • Doesn't workn ive done all the steps, but doesnt work with any of those urls : `platform/` or `http://vpscraplist.vpccpp.fr/platform/` – user3590036 Jul 01 '16 at 15:27