1

i have been through lots of topic about this, and the thing is still not working so i was wondering if you could help me to see what i am doing wrong.

My goal is to have neat URL as www.name.com without the app.php nor web, and i have changed over and over my Virtualhost & Htacces that my page are kind of gone for now^^ (Yeah so pro)

So first, i have enabled the rewrite mod, and i am running a 2.2.2 apache version.

Here is my VirtualHost files :

<VirtualHost *:80>
    ServerName steeph
    ServerAlias name.com

    DocumentRoot /home/ksc/www/symfony/web
    <Directory /home/ksc/www/symfony/web>
        AllowOverride All
        Order Allow,Deny
        Allow from all
    </Directory>

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

I have also tried with line on :

<Directory "path">
        DirectoryIndex app.php
        Options -Indexes
        AllowOverride All
        Allow from All
</Directory>

which are not working either

For my htaccess i have tried at the symfony files root (and removing the /web from the virtual host) which was a fail, and i tried with this htaccess

<IfModule mod_rewrite.c>
    RedirectMatch permanent ^/app\.php/(.*) /$1
    RewriteEngine On
    RewriteBase /web/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>

I tried with the "RedirectMatch permanent ^/app.php/(.*) /$1" and without

So i have been to like a dozen of stackoverflows and i have tried even not popular answer but it still not working, so i would really appreciate some help here

Thanks a lot!

4
  • Do you want the route mysite.com/app/whatever to be mysite.com/whatever? Because if that's the case then symfony sort of already does this for you when you're in production. You can check out what they say about it. I guess my comment is that, in the end, it's not very clear what you're asking. If you could tell us what your current URL is and what you want it to look like that would be a huge help. Commented Jan 30, 2016 at 19:14
  • mysite.com/whatever I have checked this page but i saw "Using the Apache Router is no longer considered a good practice" so i was not sure if i should follow that or not. And last point, i have tried with the "provided" .htaccess in the web folder which was not working either ^^ (oh, and i have clear my chat with php app/console cache:clear) and also tried the rm -rf app/cache/* (+ logs) Commented Jan 30, 2016 at 19:24
  • Yeah, ultimately just the regular router for the app can accomplish this. I think that was introduced in Symfony 2, maybe earlier. You can see how that's done on the routing page. One thing they don't really point out is that you may need to clear your cache with php app/console cache:clear. That has caused me a lot of headaches before. Commented Jan 30, 2016 at 19:31
  • I think this answer could help you. Commented Jan 30, 2016 at 23:21

2 Answers 2

4

If Linux... enable Rewrite

sudo a2enmod rewrite

sudo service apache2 restart

Sign up to request clarification or add additional context in comments.

Comments

0

You could just copy the one from symfony standard edition

-> https://github.com/symfony/symfony-standard/blob/master/web/.htaccess

and it would just work fine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.