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) { } ...(编辑:东莞站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- Nginx中的HSTS:是否应该在子域服务器块中添加Strict-Trans
- node.js-代理nginx Express-静态文件上的404
- centos C 为Phusion Passenger 3提供SSL支持的Curl开发标题
- linux – 无法启动php-fpm – “无法为用户’apache’获取u
- nginx try_files处理两次,如果设置了错误回退,则会失败
- linux-用apt-get vs PPA安装Node-有什么区别?
- 简单的nginx反向代理似乎剥离了一些标题
- Cookies-fastcgi缓存登录用户的方法缓存,并为每个用户自定义
- node.js – 如何在使用docker-compose时为mongodb图像添加–
- Nginx的角度为4
- java – 带有Tomcat配置的NGINX
- 铁路上的ruby-产生大量机架应用的乘客
- 代理 – 使用nginx http auth保护Jenkins,但回调
- 简单的nginx反向代理似乎剥离了一些标题
- 当响应位置的域发生变化时,使用nginx的proxy_red
- ruby-on-rails – rails – nginx puma – 静态资
- ruby-on-rails-Nginx与乘客的重写规则
- nginx – “include_recipe”与Vagrantfile“che
- python – uwsgi破管 – django,nginx
- ruby-on-rails-使用Capistrano Deploy复制Figaro
