【问题标题】:symfony 404 error - problems with mod_rewritesymfony 404 错误 - mod_rewrite 的问题
【发布时间】:2013-06-05 01:17:27
【问题描述】:

打开Symfony/web/app_dev.php 显示404 文件未找到,尝试再次打开其他页面(配置页面除外)显示404 文件未找到。我读到mod重写存在问题。

这是我的服务器配置:

server {    
        listen   80;    
        listen   [::]:80;    
        root /home/user/Projects/stereoshoots/www;    
        server_name stereoshoots.local;    

        location / {    
                autoindex  on;    
#                try_files $uri $uri/ @rewrite;    
                try_files $uri $uri/ /index.php;    
        }

#        location @rewrite {    
#                rewrite ^/(.*)$ /index.php?q=$1;    
#        }

        location ~* \.(jpg|jpeg|gif|css|png|js|ico|xml|txt)$ {    
            access_log        off;    
            expires           30d;    
        }

        location = /favicon.ico {    
                return 204;    
                access_log     off;    
                log_not_found  off;    
        }

        location ~ \.php$ {    
                fastcgi_pass unix:/var/run/php5-fpm.sock;    
                fastcgi_index index.php;    
                include fastcgi_params;    
        }

        location ~ /\.ht {    
                deny all;  
        }
}

我该如何解决这个问题?

【问题讨论】:

    标签: php mod-rewrite symfony nginx


    【解决方案1】:

    对于 symfony2 应用程序,请查看此示例配置文件以获取您正在寻找的信息: http://wiki.nginx.org/Symfony

    您希望您的服务器根目录位于 web 目录中

    root /home/user/Projects/stereoshoots/www/Symfony/web;
    

    然后将那里的所有请求重定向到app.php

    rewrite ^/app\.php/?(.*)$ /$1 permanent;
    

    【讨论】:

      猜你喜欢
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 2010-12-06
      • 1970-01-01
      • 2010-11-06
      • 1970-01-01
      • 2013-05-31
      • 2011-02-26
      相关资源
      最近更新 更多