Nginx virtual host configuration instance
1. Add the virtual host configuration at the end of the/usr/local/nginx/CONF/nginx. conf file. The instance is as follows:
Server
{
Listen 80;
SERVER_NAME www.hebaodans.com;
Index index.html index.htm index. php;
Root/wwwroot/www.hebaodans.com;
Location ~ . * \. (PhP | PhP5 )? $
{
# Fastcgi_pass Unix:/tmp/php-cgi.sock;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fcinclude gi. conf;
}
# Include rewite rule file or you can directly write here
Include rewrite. conf;
Log_format hebaodanscom '$ remote_addr-$ remote_user [$ time_local] "$ request "'
'$ Status $ body_bytes_sent' $ http_referer "'
'"$ Http_user_agent" $ http_x_forwarded_for ';
Access_log/logs/hebaodanscom. Log hebaodanscom;
}
2. Enter the following rules in VI/usr/local/nginx/CONF/Rewrite. conf:
Location /{
If (! -E $ request_filename)
{
# ---- Start ----- worldpress ----
Rewrite ^/index. php last;
# ---- End ----- worldpress ----
# -------- Zen-cart start ------
# From ultimate Seo URLs
Rewrite "^ (. *)-P-(. * ).html"/index. php? Main_page = product_info & products_id = $2 & % last;
Rewrite "^ (. *)-C-(. * ).html"/index. php? Main_page = index & cpath = $2 & % last;
Rewrite "^ (. * )-m-(%0-9%%%}.html"/index. php? Main_page = index & manufacturers_id = $2 & % last;
Rewrite "^ (. * has -pi-(%0-9%%%}.html"/index. php? Main_page = popup_image & pid = $2 & % last;
Rewrite "^ (. * has -pr-(%0-9%%%%%%.html"/index. php? Main_page = product_reviews & products_id = $2 & % last;
Rewrite "^ (. * has -pri-(%0-9%%%%%%.html"/index. php? Main_page = product_reviews_info & products_id = $2 & % last;
# For open operations info Manager
Rewrite "^ (. * has -i-(%0-9%%%}.html"/index. php? Main_page = info_manager & pages_id = $2 & % last;
# For dreamscape's News & articles manager
Rewrite "^ news /?" /Index. php? Main_page = News & % last;
Rewrite "^ news/RSS. xml"/index. php? Main_page = news_rss & % last;
Rewrite "^ news/archive /?" /Index. php? Main_page = news_archive & % last;
Rewrite "^ news/(%0-9%%%4%%%%-(%0-9%%%2%%%%-(%0-9%%2%%%%.html"/index. php? Main_page = News & date = $1-$2-$3 & % last;
Rewrite "^ news/archive/(%0-9%%%%4%%%-(%0-9%%2%%%%%.html"/index. php? Main_page = news_archive & date = $1-$2 & % last;
Rewrite "^ news/(. * has -a-(%0-9%%%-comments.html"/index. php? Main_page = news_comments & article_id = $2 & % last;
Rewrite "^ news/(. * has -a-(%0-9%%%%%.html"/index. php? Main_page = news_article & article_id = $2 & % last;
# All other pages
# Don't rewrite real files or directories
# Rewritecond % {request_filename }! -F [Nc]
# Rewritecond % {request_filename }! -D
Rewrite "^ (. * mongo.html"/index. php? Main_page = $1 & % last;
# ---------- Zen-cart end ------
}
}
After saving the settings, run kill-HUP 'cat/usr/local/nginx. Pi' and restart it smoothly.