Home > Backend Development > PHP Tutorial > Nginx CI 404 error, nginxci404 error_PHP tutorial

Nginx CI 404 error, nginxci404 error_PHP tutorial

WBOY
Release: 2016-07-12 08:58:01
Original
907 people have browsed it

Nginx CI has a 404 error, nginxci404 error

I just learned the ci framework recently and made a simple project. I have adjusted the local server environment, but deployed it to When remote server:

http://example.com/(index.php)/ can be accessed (default controller-class configured)

http://example.com/(index.php)/[controller-class]/[controller-method] cannot be accessed (prompt 404 error!)

Last Baidu reason:

For URLs like /index.php/abc, Apache and Lighttpd will interpret it as "index.php?abc", while nginx will think that the request name is "index.php" "The contents of the abc file in the directory. Therefore, CI cannot run under nginx without rewrite configured, but it works normally under Apache and Lighttpd. ​ Solution (key points are marked bold, and key points are marked red):
<span> 1</span> <span>  server {
</span><span> 2</span>         listen 80<span>;
</span><span> 3</span>         server_name <strong>example.com</strong><span>;
</span><span> 4</span>         root <strong>/data/wwwroot/example/</strong><span> 5</span>         index index.php index.html index.<span>htm;
</span><span> 6</span> 
<span> 7</span>         location ~* \.(css|js|swf|htm|jpg|png|gif|json|atlas)?<span>$ {
</span><span> 8</span> <span>            expires 1d;
</span><span> 9</span>             add_header Pragma <span>public</span><span>;
</span><span>10</span>             add_header Cache-Control "public"<span>;
</span><span>11</span> <span>        }
</span><span>12</span>         
<span>13</span>         location /<span><strong>controller-class</strong></span>/<span> {
</span><span>14</span>             <span>if</span> (!-e <span>$request_filename</span><span>) {
</span><span>15</span>                 rewrite ^/<span><strong>controller-class</strong></span>/(.*)$  /<strong><span>controller-class</span></strong>/index.php?q=<span>$uri</span>&<span>$args</span><span>;
</span><span>16</span> <span>            }
</span><span>17</span> <span>        }
</span><span>18</span>  
<span>19</span>         location ~ \.<span>php$ {
</span><span>20</span>             fastcgi_pass   127.0.0.1:9000<span>;
</span><span>21</span>             fastcgi_index  index.<span>php;
</span><span>22</span>             fastcgi_param  SCRIPT_FILENAME  <span>$document_root$fastcgi_script_name</span><span>;
</span><span>23</span>                         fastcgi_param  PHP_VALUE        open_basedir=<span>$document_root</span>:/tmp/:/proc/<span>;
</span><span>24</span>             <span>include</span><span>        fastcgi_params;
</span><span>25</span> <span>        }
</span><span>26</span> 
<span>27</span>     }
Copy after login

Reference: http://www.2cto.com/os/201301/185926.html [404 error problem with Nginx CI]

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1105554.htmlTechArticleNginx CI has a 404 error, nginxci404 error. I just learned the ci framework recently and made a simple project. I built it locally. The server environment has been adjusted, but when deployed to a remote server: http:...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template