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) { } ...(编辑:4S站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- php-主要CodeIgniter应用子目录中CodeIgniter应用的Nginx重
- nginx – 当服务器IP发生变化时,excing TCP(例如http/mysql
- nginx C IE/wget将子域的SSL证书与主域证书混淆的问题
- 在nginx下运行Lua(用Lua编写一个网站)
- Nginx返回一个假的200状态代码的空json对象
- php – Nginx:使用fastcgi_pass时覆盖主机头
- php-Magento从旧Urls重定向到具有商店(语言)代码的新Urls
- 我的nginx fastcgi配置下载php文件而不是执行它们
- Django,Apache和Nginx的配置
- 递归保护Nginx目录
- linux – 端口8080上的Gitlab
- php – 负载均衡:Nginx,Varnish和HTTP会话
- ruby-on-rails-Nginx,Unicorn和Rails = 502错误网
- 如何配置nginx php(fcgi)以使用不同的用户运行每
- 拒绝访问PHP文件(Nginx)
- linux – 如何将SSL证书从Apache服务器传输到NGI
- ruby-on-rails – 使用capistrano重新启动Rails应
- Nginx proxy_pass通过https_proxy
- apache-2.2 – 如何在HTTPS和身份验证后面提供Ma
- ruby-on-rails – nginx limit_req速率限制的问题