配置Symfony3网址

时间:2016-05-30 20:37:03

标签: php .htaccess symfony debian

我使用的是debian服务器,我想用ipAdresse:9999/app.php/register更改我的网址isAdress/register

我已成功移除.../web/...。但不是.../app.php/...

我有一个虚拟主机:

Listen ipAdress:9999

<VirtualHost ipAdress:9999>
        DocumentRoot "/var/www/SuperSwungBall/web"
        DirectoryIndex app.php


        <Directory "/var/www/SuperSwungBall/web">
                AllowOverride All
                Allow from All
        </Directory>
</VirtualHost>

〜/ web中的.htaccess:

DirectoryIndex app.php
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^app.php - [L]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>

我也尝试过使用默认的symfony~ / web / .htaccess。但是,它没有用。

谢谢!

1 个答案:

答案 0 :(得分:2)

本文介绍了几个关于如何配置您的网络服务器以通过app.php将所有请求路由到干净网址的示例:http://symfony.com/doc/2.8/cookbook/configuration/web_server_configuration.html

在您的情况下,您的虚拟主机应如下所示:

<VirtualHost *:9999>    
    DocumentRoot /var/www/SuperSwungBall/web
    <Directory /var/www/SuperSwungBall/web>
        AllowOverride None
        Order Allow,Deny
        Allow from All

        <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ app.php [QSA,L]
        </IfModule>
    </Directory>

    # uncomment the following lines if you install assets as symlinks
    # or run into problems when compiling LESS/Sass/CoffeScript assets
    # <Directory /var/www/project>
    #     Options FollowSymlinks
    # </Directory>

    <Directory /var/www/SuperSwungBall/web/bundles>
        <IfModule mod_rewrite.c>
            RewriteEngine Off
        </IfModule>
    </Directory>
    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>