Welcome! Log In Create A New Profile

Advanced

need help rewrite rule

Posted by isumido 
need help rewrite rule
November 10, 2011 03:52AM
hi all..

my english is too poor.. so sorry.


i wrote a configuration test.com.conf

# another virtual host using mix of IP-, name-, and port-based configuration

server {
listen 80;
server_name www.test.com;
rewrite ^/(.*) http://test.com/$1 permanent;
}

server {
listen 80;
server_name test.com ~^(.*)\.test\.com$;


root /home/test/public;
index index.php index.html index.htm;

error_page 401 403 404 /error.php?c=40x;
error_page 500 501 502 503 504 /error.php?c=50x;

location = /error.php {
root /home/error;
include conf.d/fastcgi;
}

location ~ \.(php|php3|html)($|/) {
fastcgi_pass localhost:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/test/public$fastcgi_script_name;
include fastcgi_params;
}


set $inNode '';
if ($host ~* ^(.+)\.test\.com$) {
set $inn $1;
set $nnt "sub";
}

if ( !-d /home/test/public/sub/$inn ) {
set $nnt "${nnt}menu";
}

if ( -d /home/test/public/sub/$inn ) {
set $nnt "${nnt}domain";
}

if ( $nnt = submenu ) {
rewrite . /index.php?c=$inn last;
}

error_page 500 = /500.html;
if ( $nnt = subdomain ) {
rewrite . /sub/$nnt/$request_uri last;
}
}


and directory and files

/home/test/public
/home/test/public/index.php

/home/test/public/sub/
/home/test/public/sub/abc
/home/test/public/sub/abc/index.php
/home/test/public/sub/abc/page.php

when i browse aaa.test.com it's http://test.com/?c=aaa
it's work.

but when i browse http://abc.test.com
it's not work. 500 error :(

but...http://abc.test.com/index.php is work.
and http://abc.test.com/index.php?c=will is not work.... 500 Error :(

how can i do it?

i wanna browse http://abc.test.com ,http://abc.test.com/?c=will and http://abc.test.com/page.php will work...

help me....
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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