標籤:apache頁面靜態化
Apache開啟靜態化頁面
博主未解決的坑:
本人首次搭建LAMP採用的是編譯安裝HTTPD服務,在開啟靜態化頁面時發現在httpd.conf中沒有LoadModule rewrite_module libexec/mod_rewrite.so代碼,手動添加進去重啟apache時報錯;
查看檔案.htaccess也正常:
# BEGIN WordPress<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule>
編譯安裝httpd的版本、參數如下:
#wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.2.31.tar.gz#tar xf httpd-2.2.31.tar.gz #cd httpd-2.2.31#yum install zlib zlib-devel -y./configure --prefix=/application/apache2.2.31 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite#make#make install
總之問題為解決
本著簡單、易用、高效的原則,本人建議採用yum安裝;
Apache實現靜態化頁面的實際操作:
設定檔httpd.conf中:
AllowOverride None 改為 AllowOverride All
檔案中要有LoadModule rewrite_module libexec/mod_rewrite.so,代碼前若有#注釋,把注釋去掉,若沒有此代碼則手動添加進去;
.htaccess檔案:
# BEGIN WordPress<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule>
檔案中若沒有上述代碼則手動添加到檔案中
本文出自 “小新” 部落格,請務必保留此出處http://zhanghongxin.blog.51cto.com/11255031/1853409
apache靜態化頁面