配置 Symfony3 URL

Config Symfony3 URL

我使用的是 debian 服务器,我想将 URL 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 。但是,它不起作用。

谢谢!

本文介绍了几个示例,介绍了如何配置您的网络服务器以通过 app.php 路由所有请求,并使用干净的 URL: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>