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) { } ...(编辑:岳阳站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- PHP-访问控制器时,nginx上Codeigniter出现404错误
- reactjs – 如何配置我的Nginx服务器以使用子文件夹中的Rea
- 如何告诉nginx仅为一个vhost管理的域提供https?
- 配置Nginx以使Angular 2快速入门与Browsersync一起使用
- python – nginx和uwsgi服务器中的uwsgi模块之间的区别
- node.js – 如何从作为nodejs服务器的反向代理的nginx服务器
- 403禁止 – Nginx – 使用正确的凭据
- Ubuntu 14.04中缺少nginx php5-fpm conf文件
- Kubernetes Nginx:如何实现零停机部署?
- Nginx php-fpm随机挂起
- 如何使用nginx将请求代理到内部服务器?
- nginx-加载SVG时出错-ERR_CONTENT_DECODING_FAIL
- linux – nginx和cloudlfare ip混淆?
- apache – Symfony2:由于已经发送了标头,因此无
- nginx要怎么配置rewrite才能运行vephp、yii和thi
- ruby – Gitlab配置问题:: NGINX Unicorn端口冲突
- Nginx:将https://重写为http://
- apache-2.2 – 使用Nginx进行严格的安全性和虚拟
- 如何根据Nginx中的请求URL重定向到特定的上游服务
- php – 使用sendgrid发送邮件时出错的凭据