简体   繁体   English

配置Symfony3 URL

[英]Config Symfony3 URL

I use a debian server and I want change my URL ipAdresse:9999/app.php/register with isAdress/register . 我使用的是Debian服务器,我想用isAdress/register更改URL ipAdresse:9999/app.php/register isAdress/register

I have succeed to remove the .../web/... . 我已经成功删除了.../web/... But not the .../app.php/... 但不是.../app.php/...

I have a virtual host : 我有一个虚拟主机:

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>

And a .htaccess in ~/web : 在〜/ 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>

I have also tried with the default symfony ~/web/.htaccess . 我也尝试使用默认的symfony〜/ web / .htaccess。 But, it doesn't work. 但是,它不起作用。

Thanks ! 谢谢 !

This article describes a couple of examples on how to configure your webserver to route all requests through app.php with clean URL's: http://symfony.com/doc/2.8/cookbook/configuration/web_server_configuration.html 本文介绍了几个有关如何配置您的网络服务器以使用干净的URL通过app.php路由所有请求的示例: http : //symfony.com/doc/2.8/cookbook/configuration/web_server_configuration.html

In your case your virtual host should look something like: 在您的情况下,您的虚拟主机应类似于:

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM