程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> apache中訪問不了偽靜態頁面的解決方法

apache中訪問不了偽靜態頁面的解決方法

編輯:MySQL綜合教程

1、安裝
復制代碼 代碼如下:
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-ssl

這時apache已經擁有的偽靜態功能了,稱為內建偽靜態。

2、如果安裝的時候沒有  --enable-rewrite  這個參數,那麼:
到“LoadModule” 區域,在最後一行加入“LoadModule rewrite_module modules/mod_rewrite.so”(必選獨占一行),然後重啟apache服務器即可。

3、讓apache服務器支持.htaccess
vim /usr/local/apache2/conf/extra/http-vhosts
Options FollowSymLinks
AllowOverride None
改為
Options FollowSymLinks
AllowOverride All
就可以了。
但是需要在網站文件中加入一個htaccess文件。才可以綜合支持偽靜態功能。(在網站文件目錄下)
vim .htaccess

復制代碼 代碼如下:
RewriteEngine On
RewriteBase /
# Rewrite規則
RewriteRule ^index\.htm$ index\.php
RewriteRule ^jobs/jobs-show-([0-9]+)\.htm$ jobs/jobs-show\.php\?id=$1
RewriteRule ^company/company-show-([0-9]+)\.htm$ company/company-show\.php\?id=$1
RewriteRule ^resume/resume-show-([0-9]+)\.htm$ resume/resume-show\.php\?id=$1
RewriteRule ^news/news-list-([0-9]+)-([0-9]+)\.htm$ news/news-list\.php\?id=$1&page=$2
RewriteRule ^news/news-show-([0-9]+)\.htm$ news/news-show\.php\?id=$1
RewriteRule ^explain/explain-show-([0-9]+)\.htm$ explain/explain-show\.php\?id=$1
RewriteRule ^notice/notice-list-([0-9]+)-([0-9]+)\.htm$ notice/notice-list\.php\?id=$1&page=$2
RewriteRule ^notice/notice-show-([0-9]+)\.htm$ notice/notice-show\.php\?id=$1

偽靜態報錯:
主站好用,但是鏈接不好用。鏈接是一個靜態頁面。以.html結尾的,所以我判斷,就是為靜態頁面沒生效,所以就添加.htaccess文件即可。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved