天天看點

wamp本地環境為靜态與lnmp內建環境下nginx為zencart的靜态配置

wamp本地環境為靜态配置篇:

第一步:找到Apache安裝目錄下httpd.conf這個檔案,搜尋找到,“LoadModulerewrite_module modules/mod_rewrite.so”,找到這一行,去掉前面的“#”;

第二步:找到

AllowOverride None
           
AllowOverride All.
           

第三步:重新開機apache

第四步:建立.haccess檔案,放在目前網站根目錄下,在.haccess檔案中寫僞靜态規則,看示例

RewriteEngine on

RewriteBase /

RewriteRule ^article\.html$ /article.php 

RewriteRule ^article\_(+)\.html$/article.php?page=$1 

到此就完成了。

nginx伺服器為靜态配置:

LNMP預設添加了Discuz、Wordpress、Sablog、emlog、dabr等僞靜态支援,在建立虛拟主機時,輸入以上名稱就能 對上述程式僞靜态完美支援。

如果,您還需要添加自定義僞靜态規則,直接輸入一個你想要的僞靜态規則的名稱,然後編輯/usr/local/nginx /conf/你自定義的僞靜态名字.conf 裡面添加僞靜态規則。

在這裡記錄下我本人以前添加的一個關于zencart的記錄:

在安裝lnmp環境的時候寫的一個為靜态檔案名稱是叫other.conf;

是以就要在/usr/local/nginx/conf/下添加other,conf這個為靜态規則檔案;

内容如下:

location / {

if (!-e $request_filename)
{
#————————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 "^(.*)-pi-([0-9]+).html" /index.php?main_page=popup_image&pID=$2&% last;
rewrite "^(.*)-pr-([0-9]+).html" /index.php?main_page=product_reviews&products_id=$2&% last;
rewrite "^(.*)-pri-([0-9]+).html" /index.php?main_page=product_reviews_info&products_id=$2&% last;

# For Open Operations Info Manager
rewrite "^(.*)-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/(.*)-a-([0-9]+)-comments.html" /index.php?main_page=news_comments&article_id=$2&% last;
rewrite "^news/(.*)-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 "^(.*).html" /index.php?main_page=$1&% last;
#—————————-zen-cart end—————–

}
}
           

差不多就是這些了。

有疑問歡迎大家交流,更歡迎高手拍磚。

繼續閱讀