Welcome! Log In Create A New Profile

Advanced

Apache rewriterule to nginx rewriterule

Posted by bobsona1 
Apache rewriterule to nginx rewriterule
January 26, 2013 04:09AM
Hello,
I moved my website from cPanel server with Apache to IspConfig3 server with nginx.
My problem is that these current lines for mod_rewrite don't work in nginx...

RewriteEngine on
RewriteRule ^blog/(.*)/?$ /blogview.php?id=$1
RewriteRule ^blog/category/(.*)/?$ /blog_category.php?id=$1
Options -Indexes

Can anyone help me ?
Sorry for my English... :)
Re: Apache rewriterule to nginx rewriterule
February 11, 2013 12:03PM
I haven't tried this but give it a go: http://www.anilcetin.com/convert-apache-htaccess-to-nginx/
Re: Apache rewriterule to nginx rewriterule
May 07, 2013 07:56AM
Maybe too late, but it's best to avoid rewrites at all. Use location captures, instead:

location ~ ^/blog/(?<id>.*)/$ {
include fastcgi_params;
fasctgi_param SCRIPT_FILENAME $document_root/blog_view.php;
fastcgi_param QUERY_STRING id=$id&$args;
fastcgi_pass ...; # path to your php-fpm socket
}

location ~ ^/blog/category/(?<id>.*)/$ {
include fastcgi_params;
fasctgi_param SCRIPT_FILENAME $document_root/blog_category.php;
fastcgi_param QUERY_STRING id=$id&$args;
fastcgi_pass ...; # path to your php-fpm socket
}



Andrejs
loco (at) andrews.lv



Edited 1 time(s). Last edit at 05/07/2013 07:56AM by locojohn.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 187
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready