Thursday, April 12, 2012

Really simple Nginx rewrite to index.php needed, unable to find the solution

I used the .htaccess to nginx rewrite converter and the solution is not working. In fact I'm unable to get any of my rewrites working no matter what I try. I am obviously doing something wrong here. Here's my minimalistic Nginx.conf file:



worker_processes  1;
events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;

location / {
root html;
index index.html index.htm;
}

# Make sure to set this as your actual server WWW root
root html;
# Index file
index index.php;
# Rewrite that directs everything to index file
rewrite /!^(.*).php$ /./index.php last;

location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}


I even tried things like "rewrite index.php" with no success. I also tried to put the rewrite in a separate location tag, but that made no difference either.



What am I doing wrong?





No comments:

Post a Comment