Routing issues in symfony2 project
仅有的幸福
仅有的幸福 2017-05-16 16:44:43
0
1
467

My project home page URL is http://localhost/lcode/web/app_dev.php
Then all URLs accessed by {{ path('abc') }} will have localhost/lcode/web/app_dev.php
This paragraph
Now I want to use gzl to replace this
For example, the home page access is http://gzl

仅有的幸福
仅有的幸福

reply all(1)
左手右手慢动作

It’s ok.
os: windows 7
server: nginx

1. Configure nginx

Create a new virtual host in the nginx.conf file. The configuration code is as follows:

server {
    listen 80;

    server_name www.caiwen.org;
    try_files $uri $uri/ /app_dev.php?$query_string;

    # 如果URL中包含app_dev.php,则转发为伪静态格式
    rewrite ^/app_dev\.php/?(.*)$ / permanent;

    location / {
        index app_dev.php;
        root  D:/WebRoot/caiwen/codes/web;
        try_files $uri @rewriteapp;
    }

    location @rewriteapp {
        rewrite ^(.*)$ /app_dev.php/ last;
    }

   location ~ \.php {
        root           D:/WebRoot/caiwen/codes/web;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  app_dev.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

2. Configure hosts file

Under Windows, use Notepad to open the C:WindowsSystem32driversetchosts file and add a line

127.0.0.1   www.caiwen.org

Under ubuntu, vim /etc/hosts

It’s OK.
In this way, you can use www.caiwen.org to access the website in Browser without adding /codes/web/app_dev.php at the end.

You can refer to my configuration file to complete your configuration. Pay attention to the amazing path.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template