RewriteRule in Apache with Symfony2 not removing app.php

前端 未结 7 1998
佛祖请我去吃肉
佛祖请我去吃肉 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:33

    That rewrite rule is not meant to remove app.php from the URL. It's purpose is to use app.php for every request, if a request URL doesn't correspond to a real file. Since app.php is a real file, it will be used to serve a request.

    If you want get rid of web/app.php part, first create a virtual host pointing to the web folder:

    
        ServerName whatever
        DocumentRoot /path/to/project/web
    
    

    This will remove the web part.

    Then, to remove the app.php part, add this to the beginning of the web/.htaccess file:

    RedirectMatch permanent ^/app\.php/(.*) /$1
    

提交回复
热议问题