Welcome! Log In Create A New Profile

Advanced

Help me! please..

Posted by isumido 
Help me! please..
November 09, 2011 09:44AM
hi... users.


/home/test/public
/home/test/public/subdomain
/home/test/public/subdomain/greeting

i wrote rewrite rule

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

if(!-d /home/test/public/subdomain/$1) {
set $inn $1;
rewrite ^\?(.*) http://test.com/?page=$inn$requesturi? last;
rewrite . http://test.com/?page=$inn last;
}

root /home/test/public/subdomain;
index index.php;
}

server {
server_name test.com
root /home/test/public;

location ~ \.php$ {
fastcgi_pass http://localhost:9000;
fastcgi_param /home/test/public$fastcgi_script_name;
include fastcgi_params;
}
}


when i connent to http://test.com, OK
when i connect http://bye.test.com, will be http://test.com/?page=bye.

but... i dont wanna redirect http://test.com/?page=bye.

want.. browser address is remain 'http://bye.test.com'
and its contents is same http://test.com/?page=bye.

how can i do it?


and subdomain http://greeting.test.com/test.html is OK.
but http://greeting.test.com/test.php is not work. T.T
just text or 404 Error..

please help me.

how can i do it?

thx..
Re: Help me! please..
November 10, 2011 08:31AM
If I understood you correctly:


server {
server_name ~^(?<subdomain>.+)\.test\.com$;

if (!-d /home/test/public/subdomain/$subdomain) {
rewrite ^ http://test.com/?page=$subdomain$request_uri? last;
}

root /home/test/public/subdomain/$subdomain;
index index.php;

location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}

}

server {
server_name test.com;

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

location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}
Re: Help me! please..
November 10, 2011 08:45AM
wow Mr.locojohn!!
good work.~!!

nice.~ thx!!! thx so much!!!!

im kissing you!!!!!



Edited 1 time(s). Last edit at 11/10/2011 08:47AM by isumido.
Mr.locojohn...
November 10, 2011 10:38AM
thx for reply..
and.. i modify configuration file.


first, i made folders.

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

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

/home/error/error.php

and test.com.conf

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

server {
listen 80;
server_name test.com ~^(?<subdomain>.+)\.test\.com$;

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

# Set this to off if you're hosting more than one site
#server_name_in_redirect off;

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

location = /error.php {
root /home/test/error;
fastcgi_pass http://localhost:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} }

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.(php|php3|inc|html)($|/) {
fastcgi_pass http://localhost:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

if ($host ~* ^(?<subdomain>.+)\.test\.com$) {
set $NodeType sub;
}

if ( !-d /home/test/public/subdomain/$subdomain ) {
set $NodeType "${NodeType}menu";
}

if ( -d /home/test/public/subdomain/$subdomain ) {
set $NodeType "${NodeType}domain";
}

if ( $NodeType = submenu ) {
rewrite ^ /index.php?c=$sub last;
}

if ( $NodeType = subdomain ) {
rewrite ^ /subdomain/$sub$request_uri$args? last;
}
}



1. rewrite
http://test.com and http://www.test.com is work.
http://abc.test.com/index.php and http://abc.test.com/page.php is OK.
http://menu.test.com is OK.

but

http://abc.test.com 500 Error
http://abc.test.com/index.php?type=abc 500 Error

omg...:(
how can i correct it?

2. error page
http://test.com/aaaaa.php 404 Error ( it's OK custom page )

but http://abc.test.com/aaaaaa.php 404 Error ( it's not custom page )

please help me.

thx...
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 113
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready