yii實現偽靜態

2021-06-25 07:28:16 字數 1798 閱讀 1361

一:

調整apache配置檔案httpd.conf,重啟apache伺服器。。。

1. 裝載rewrite_module模組

loadmodule rewrite_module modules/mod_rewrite.so

2. 相對應目錄的allowoverride修改為all

documentroot "/users/dream/documents/sites"

## possible values for the options directive are "none", "all",

# or any combination of:

#   indexes includes followsymlinks symlinksifownermatch execcgi multiviews

## note that "multiviews" must be named *explicitly* --- "options all"

# doesn't give it to you.

## the options directive is both complicated and important.  please see

# # for more information.

##options indexes followsymlinks

# xampp

options indexes followsymlinks execcgi includes

## allowoverride controls what directives may be placed in .htaccess files.

# it can be "all", "none", or any combination of the keywords:

#   options fileinfo authconfig limit

##allowoverride none

# since xampp 1.4:

allowoverride all

## controls who can get stuff from this server.

#require all granted

二 確保apache載入mod_rewrite模組,通過phpinfo()檢視(http://localhost/xampp/)

三 在根目錄下,即在index.php同級目錄下新建.htaccess檔案,內容如下:

options +followsymlinks

indexignore */*

rewriteengine on

# if a directory or a file exists, use it directly

rewritecond % !-f

rewritecond % !-d

# otherwise forward it to index.php

#rewriterule . index.php

rewriterule  ^(?!server-status).*?$ index.php

四 編輯配置yii的配置檔案main.php,配置urlmanager元件

'urlmanager'=>array(

'urlformat'=>'path', //改為path格式路徑

'showscriptname'=>false,//去掉index.php

'rules'=>array(

'/'=>'/view',

'//'=>'/',

'/'=>'/',

),),

偽靜態的實現

所謂的偽靜態頁面,就是指的url重寫,在asp.net中實現非常簡單 首先你要在你的專案裡引用兩個dll actionlessform.dll urlrewriter.dll 真正實現重寫的是 urlrewriter.dll 但是如果你要實現分頁,那麼必須使用這個actionlessform dll...

apache實現偽靜態

首先在apache裡開啟配置檔案httpd.conf,找到loadmodule rewrite module modules mod rewrite.so,將前面的 號刪掉,如果沒有這句話則自己新增一句。一般有倆種方法可以重寫url 第一 如果有修改httpd.conf許可權,可以直接在httpd....

UrlRewrite實現偽靜態

web.xml中配置 urlrewritefilter org.tuckey.web.filters.urlrewrite.urlrewritefilter loglevel debug html web int下面新增 urlrewrite.xml ule結點中form的規則預設使用的是正規表示式...