Welcome! Log In Create A New Profile

Advanced

Rewrite or Fastcgi Params?

Posted by allentkw 
Rewrite or Fastcgi Params?
September 20, 2010 02:02PM
Hi!

Recently I setup a box using nginx 0.8.50 + php to serve Wordpress. Currently right now stuck on which method should I use to support Wordpress URL rewrites.

From what I understand through the Wiki, I am able to serve content with pretty URLs:
[code]
location / {
try_files $uri $uri/ @wordpress;
}

location @wordpress {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param QUERY_STRING q=$uri&$args;
fastcgi_pass my_php;
}
[/code]

I have also searched through the forums and other websites with similar setup:
[code]
location / {
try_files $uri $uri/ @wordpress;
}

location @wordpress {
rewrite ^/(.*)$ /index.php?q=$1 last;
}

location ~ \..*/.*\.php$ {
return 403;
}

location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass unix:/var/run/php-fpm.sock;
}
[/code]

After checking the nginx wiki - Pitfalls, I modify the above to this:
[code]
location / {
try_files $uri $uri/ @wordpress;
}

location @wordpress {
rewrite ^ /index.php?q=$uri&$args last;
}

location ~ \..*/.*\.php$ {
return 403;
}

location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass unix:/var/run/php-fpm.sock;
}
[/code]

Which one will be the best recommended setup? I understand that a vulnerability exists if I use a global php parse directive, that is why I have another directive to prevent that.

Is there any difference between the one recommended in the wiki and those from other websites? Since the wiki's is redirecting the parsing of the url internally without the use of rewriting whereas the others are using it. And rewriting means converting a piece of url in the server, therefore can I safely assume that what is recommended in the Wiki is the same as using the rewrite functions? Maybe with performance boost since there is no need to call upon the rewrite function?



Edited 1 time(s). Last edit at 09/20/2010 02:08PM by allentkw.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 163
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready