求nginx下分站二级域名的伪静态规则
用的php168的分类信息程序,参照官方给的apache规则已经实现了二级目录的写法
下面rewrite部分应该是正确的吧,求server部分写法,万分感谢
server {
server_name www.XXX.com XXX.com *.XXX.com;
}
location / {
rewrite ^(.*)/(list|bencandy)-([^.]+).([a-zA-Z0-9]+)$ $1/$2.php?stringID=$3 last;
rewrite ^/([^/]+)/f([^/]+).([a-zA-Z0-9]+)$ /bencandy.php?Fid=$1&Id=$2 last;
rewrite ^/([^/]+)/([^/]+)/$ /list.php?Fid=$2&zone_street=$1 last;
rewrite ^/([^/]+)/$ /list.php?Fid=$1 last;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
凡是宏哥说的都是对的, 凡是宏哥提倡的都要坚持.
Catchall 的设置:
# You may add here your
# server {
# ...
# }
# statements for each of your virtual hosts
server {
listen 80 default;
server_tokens off;
charset utf-8;
server_name ~^(?:(.*).)?(.*).(.*)$;
set $sub_parse $1;
set $sub 'www';
if ($sub_parse){
set $sub $sub_parse;
}
set $domain $2;
set $domain_type $3;
if ($sub_parse !~ (w+)){
rewrite (.*) http://$sub.$domain.$domain_type$request_uri permanent;
}
access_log /var/log/nginx/$sub.$domain.$domain_type.access.log;
root /var/www/sites/$domain_type/$domain/$sub;
gzip off;
gzip_static on;
index index.html;
#This is to redirect when Direct not exists
error_page 403 =200 /index.php;
location /favicon.ico {
root /var/www/default;
}
location /{
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php;
}
if (-e $request_filename){
expires modified +7d;
}
location ~ .php$ {
fastcgi_pass unix:/var/run/fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /webserver/dep/run/ccd/index.php;
# fastcgi_param HTTPS yes;
include /etc/nginx/fastcgi_params;
}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/default;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$ {
#proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on unix:/var/run/fpm.sock
#
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /.ht {
#deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#listen 8000;
#listen somename:8080;
#server_name somename alias another.alias;
#location / {
#root html;
#index index.html index.htm;
#}
#}
# HTTPS server
#
#server {
#listen 443;
#server_name localhost;
#ssl on;
#ssl_certificate cert.pem;
#ssl_certificate_key cert.key;
#ssl_session_timeout 5m;
#ssl_protocols SSLv2 SSLv3 TLSv1;
#ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
#ssl_prefer_server_ciphers on;
#location / {
#root html;
#index index.html index.htm;
#}
#}
以后问问题,可以现在
stackoverflow找答案,找不到再问。注意要问的是问题。