server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/rjf611/www/aimooc;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name 你的域名;
#此为网站的主页设置或者叫根目录设置
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
#此为二级目录weibo的伪静态设置
#weibo static url
location /weibo/ {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /weibo/index.php;
}
}
#......
#下面还有,但是本篇只是说二级目录的url伪静态,因此下面的就不赘述了。