小编blk*_*kmr的帖子

用Nginx和PHP重写fastcgi仍然将旧的request_uri发送到后端(php和symfony)

我试图将运行symfony框架的php网站迁移到nginx和php over fastcgi.

http://wiki.nginx.org/开始使用Symfony howto一切正常,但我遇到了自定义重写规则的问题.

我的目标是将/ aaaa形式的URL重写为/ view/shorthand/aaaa.然后应该由php和symfony对请求进行处理.

旧的apache重写规则:

RewriteRule ^([0-9a-f]+)$ index.php/view/shorthand/$1 [L]
Run Code Online (Sandbox Code Playgroud)

我尝试过的Nginx规则:

rewrite ^/([0-9a-f]+)$ /view/shorthand/$1 break;
rewrite ^/([0-9a-f]+)$ /index.php/view/shorthand/$1 break;
Run Code Online (Sandbox Code Playgroud)

他们都被发送到fastcgi但是request_uri似乎仍然是/ aaaa,因为我收到此错误:

FastCGI sent in stderr: "Action "aaaa/index" does not exist" while reading response header from upstream
Run Code Online (Sandbox Code Playgroud)

我也尝试过使用try_files而没有任何运气.请指教.

php symfony1 fastcgi nginx url-rewriting

5
推荐指数
1
解决办法
4739
查看次数

标签 统计

fastcgi ×1

nginx ×1

php ×1

symfony1 ×1

url-rewriting ×1