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

來源:互聯網
上載者:User

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檔案即可。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.