Note that there are some explanatory texts on larger screens.

plurals
  1. PONginx rewrite rule for CodeIgniter
    primarykey
    data
    text
    <p>Here is the rule in English:</p> <blockquote> <p>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.</p> </blockquote> <p>I have an <code>.htaccess</code> file that works correctly on Apache server:</p> <pre><code>RewriteCond $1 !^(index\.php|assets|files|robots\.txt) RewriteRule ^(.*)$ index.php/$1 [L] </code></pre> <p>Some correct results for this rule:</p> <p><code>example.com</code> = <code>example.com/index.php</code></p> <p><code>example.com/index.php/welcome</code> = <code>example.com/welcome</code></p> <p><code>example.com/assets/css/main.css</code> <strong>!=</strong> <code>example.com/index.php/assets/css/main.css</code></p> <p>I tried some tools to convert from htaccess rule to nginx rule but all were incorrect.</p> <p>Via <a href="http://winginx.com/htaccess" rel="nofollow">http://winginx.com/htaccess</a> (missing the exception rules for assets folder...):</p> <pre><code>location / { rewrite ^(.*)$ /index.php/$1 break; } </code></pre> <p>Via <a href="http://www.anilcetin.com/convert-apache-htaccess-to-nginx/" rel="nofollow">http://www.anilcetin.com/convert-apache-htaccess-to-nginx/</a> (error in $1 value):</p> <pre><code>if ($1 !~ "^(index.php|assets|files|robots.txt)"){ set $rule_0 1$rule_0; } if ($rule_0 = "1"){ rewrite ^/(.*)$ /index.php/$1 last; } </code></pre> <p>How can I fix this? It's really hard to debug the rule.</p> <p>Here is my nginx config so far:</p> <pre><code>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; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload