php C CodeIgniter的Nginx重写规则
Any HTTP request other than those for index.php,assets folder,files folder and robots.txt is treated as a request for your index.php file.
我有一个.htaccess文
这是英文规则: Any HTTP request other than those for index.php,assets folder,files folder and robots.txt is treated as a request for your index.php file. 我有一个.htaccess文件,可以在Apache服务器上正常工作: RewriteCond $1 !^(index.php|assets|files|robots.txt) RewriteRule ^(.*)$index.php/$1 [L]此规则的一些正确结果: example.com = example.com/index.php example.com/index.php/welcome = example.com/welcome example.com/assets/css/main.css!= example.com/index.php/assets/css/main.css 我尝试了一些工具从htaccess规则转换为nginx规则,但都是不正确的. 通过http://winginx.com/htaccess(缺少资产文件夹的例外规则……): location / { rewrite ^(.*)$/index.php/$1 break; }通过http://www.anilcetin.com/convert-apache-htaccess-to-nginx/($1值中的错误): if ($1 !~ "^(index.php|assets|files|robots.txt)"){ set $rule_0 1$rule_0; } if ($rule_0 = "1"){ rewrite ^/(.*)$/index.php/$1 last; }我怎样才能解决这个问题?调试规则真的很难. 到目前为止,这是我的nginx配置: server { listen 80; server_name www.example.com example.com; location / { try_files $uri $uri/ /index.php?/$request_uri; } location ~ .php${ root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; include fastcgi_params; } location ~ /.ht { deny all; } } 最佳答案 您可以将其添加到您的配置: location ~* ^/(assets|files|robots.txt) { }这将适用于您的位置/规则. 您的配置还需要添加根文档和默认索引文件. ... root /ftp/wardrobe; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?/$request_uri; } location ~* ^/(assets|files|robots.txt) { } ...(编辑:鲜蔬坊站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- node.js-矛盾的CORS错误:不存在“ Access-Control-Allow-O
- 通过nginx替换指纹文件服务器时,在浏览器中过期资产缓存
- Nginx C 根据server_name更改根目录?
- Nginx:将所有不存在的请求重定向到index.php
- 在django nginx wsgi中,什么是“mysite.sock”
- 仅在一个站点上显示PHP错误
- Gitlab:使用Passenger / Nginx运行Unicorn,Resque的问题
- apache-2.2 – 来自后端的301的nginx负载均衡问题
- Nginx proxy_pass到密码保护上游
- ruby-on-rails – 如何使用不同的用户运行nginx主进程
- nginx是否在提供静态文件时调用了外部脚本(传递请
- ubuntu – 如何通过不同的端口启动nginx(80以外的
- 在userdir中使用nginx运行Moodle(斜杠参数)
- 运行fastcgi- php作为博客子文件夹,而网站的其余
- ruby-on-rails-4 – 使用AWS Elastic Beanstalk运
- Nginx和FastCGI下载PHP文件而不是处理它们
- 使用PHP5-FPM的Nginx-提供空白屏幕的.php文件
- nginx客运轨道 – 403禁止错误
- nginx中的动态proxy_pass到Kubernetes中的另一个
- 使用Nginx fastcgi_cache php-fpm缓存和静态文件