Note that there are some explanatory texts on larger screens.

plurals
  1. POnginx with rewrite
    primarykey
    data
    text
    <p>Just perform an installation of Nginx, PHP, following this <a href="http://www.howtoforge.com/installing-nginx-with-php5-and-php-fpm-and-mysql-support-on-ubuntu-11.10" rel="nofollow noreferrer">tutorial</a> and all is well. Upon entering the url <a href="http://192.168.1.10" rel="nofollow noreferrer">http://192.168.1.10</a> shows me the welcome screen. Now create a folder called <code>test</code> and want to implement something like apache mod-rewrite, so that upon entering <a href="http://192.168.1.10/test/my-test/" rel="nofollow noreferrer">http://192.168.1.10/test/my-test/</a> call <code>index.php?x=my-test</code></p> <p>The modified <code>sites-avaible/default</code> looks like this:</p> <pre><code>server { listen 80; ## listen for ipv4; this line is default and implied listen [::]:80 default ipv6only=on; ## listen for ipv6 #root /usr/share/nginx/www; root /var/www/; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html #try_files $uri $uri/ /index.html; } location /test{ if (-f $request_filename) { break; } if (-d $request_filename) { break; } rewrite ^(.+)/$ /index.php?x=$1 last; } location /doc { root /usr/share; autoindex on; allow 127.0.0.1; deny all; } location /images { root /usr/share; autoindex off; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { fastcgi_pass unix:/tmp/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } } </code></pre> <p>It does not work as expected. If I go to <a href="http://192.168.1.10/test/my-test/" rel="nofollow noreferrer">http://192.168.1.10/test/my-test/</a> what happens is it shows me the value of the index of <a href="http://192.168.1.10/" rel="nofollow noreferrer">http://192.168.1.10/</a>.</p> <p><img src="https://i.stack.imgur.com/fZsNM.jpg" alt="Attached image"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
 

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