1

Although I've spent 2 days reading on forums, I still can't get some Codeigniter rewrites working in Nginx. Here is the server configuration:

server { listen *:80; server_name artademy.com www.artademy.com; root /var/www/artademy.com/web; index index.html index.htm index.php index.cgi index.pl index.xhtml; if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?/$1; } if (!-e $request_filename) { rewrite ^/(index.php\?)/(.*)$ /$1/mobile_app last; break; } error_log /var/log/ispconfig/httpd/artademy.com/error.log; access_log /var/log/ispconfig/httpd/artademy.com/access.log combined; ## Disable .htaccess and other hidden files location ~ /\. { deny all; access_log off; log_not_found off; } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location /stats { index index.html index.php; auth_basic "Members Only"; auth_basic_user_file /var/www/clients/client0/web3/.htpasswd_stats; } location ^~ /awstats-icon { alias /usr/share/awstats/icon; } location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9012; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_intercept_errors on; } } 

Codeigniter settings are: well for uri_protocol: REQUEST_URI;

What I noticed is that from this rule: rewrite ^/(.*)$ /index.php?/$1; it works, but if I write it like this: rewrite ^/(.*)$ /index.php?;. It might be a wild guess but it stops at the question mark.

Anyhow what I need are rules as these from .htaccess:

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{QUERY_STRING} ^lang=([a-z]{2})$ RewriteRule ^([a-z]{2})$ index.php?/home_page?lang=$1 [L,QSA] RewriteRule ^([a-z]{2})$ index.php?/home_page?lang=$1 [L,QSA] #how_it_works RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^how-it-works/(en)$ index.php?/how_it_works?lang=en [L,QSA] #order_status RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^order-status/(en)$ index.php?/order_status?lang=en [L,QSA] 

Can anyone tell me what I'm doing wrong and show me a proper way for at least one rule? It would be more than helpful. Thank you in advance! ^^

PS: I made it work on apache by using Path_info for uri_protocol. If this info is of any help. I remember having kind of the same problem there too but switching to path_info made it all good.

PS.2: My .htaccess is working fine, that I am sure. For example I want to rewrite from artademy.com/how-it-worksES/es to arademy.com/index.php?/how_it_works?lang=es

6
  • Your Nginx's rewrite rule does not correspond to the Apache's .htaccess. Please give us an example of URL and what you want to rewrite to. Moreover, are you sure your .htaccess is working fine? Commented Sep 7, 2012 at 3:04
  • .htaccess is working fine, i posted it as an example for what i need on nginx. I edited with a PS2 for a clear example of what i need Commented Sep 7, 2012 at 9:06
  • how-it-worksES? Commented Sep 7, 2012 at 9:47
  • the ES is just a temporary thing until the final url are decided. anyhow, try showing me without "ES" Commented Sep 7, 2012 at 10:03
  • This sentence does not make sense to me: "Codeigniter settings are: well for uri_protocol: REQUEST_URI;" Can you clarify what you mean? Commented Oct 2, 2012 at 10:44

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.