RewriteRule in Apache with Symfony2 not removing app.php

前端 未结 7 1999
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 15:34

I have the following .htaccess file in my web directory for my Symfony2 installation:


    RewriteEngine On
    RewriteCond %{R         


        
7条回答
  •  眼角桃花
    2020-12-13 16:16

    I managed to remove web/app.php part on my shared server.

    1. First I moved app.php out of the web directory one step above thus my app.php on the root directory. Then I placed a .htaccess on the root directory
    RewriteEngine on
    
    RewriteBase /
    
    RewriteRule ^css/(.*) web/css/$1
    
    RewriteRule ^images/(.*) web/images/$1
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app.php [QSA,L]
    

    I used RewriteCond on css and images as they still lie inside /web/ directory so all request to css and images will be routed to web/css and web/images directories respectively.

    It worked well for me.

提交回复
热议问题