Welcome! Log In Create A New Profile

Advanced

nginx rewrite expression dilemma

June 25, 2012 06:39AM
Hi,

Having following apache config working:

=========================================================

<Directory /data/www/dev/domain.com/cf/htdocs/get>
Options FollowSymlinks
RewriteEngine on
RewriteRule ^([^/\.]+)/([^/]+)$ index.php?contid=$1 [L]
</Directory>

=========================================================

Rewrite works properly, when pointing to domain.com/get/aa/bb

I can't get this working properly in nginx using the following config:
When I enter URL that works in apache, nginx returns with 404.

=========================================================
upstream cf-domain {

server unix:/data/www/dev/domain.com/cf/cf-domain.sock;
}


server {
listen 62.236.108.22:80;
listen 127.0.0.1:28005;
server_name cfdev.domain.com;
access_log /data/www/dev/domain.com/cf/logs/frontend/access.log;
error_log /data/www/dev/domain.com/cf/logs/frontend/error.log;

charset utf-8;

location ~ ^/get/ {
rewrite ^([^/\.]+)/([^/]+)$ index.php?contid=$1 last;
fastcgi_pass cf-domain;
}

location / {
root /data/www/dev/domain.com/cf/htdocs;
index index.php index.html;

if ($request_uri ~* "\.(ico|css|js|gif|jpe?g|png)$") {
expires max;
}

if (!-f $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
break;
}
}

location ~ (\.php)$ {
fastcgi_param SCRIPT_FILENAME /data/www/dev/domain.com/cf/htdocs$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include /etc/nginx/fastcgi_params;
fastcgi_pass cf-domain;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

=========================================================

I suspect I need to amend processing order or rewrite, but can't seem to find the right way. Can you please help me to find where the error is?
Subject Author Posted

nginx rewrite expression dilemma

technoplague June 25, 2012 06:39AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 299
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