1. 編輯 conf/conf.php
找到 'urlrewrite' => 0, 修改為:
'urlrewrite' => 1,
2. 清空 tmp 目錄
3. 修改 Web Server 的 Rewrite 規(guī)則,以下為各種Web Server 的樣例:
其實(shí)很簡單,就是將 xxx.htm 轉(zhuǎn)發(fā)到 index.php?xxx.htm
Nginx:
打開 nginx 配置文件 /usr/local/nginx/conf/nginx.conf 找到對(duì)應(yīng)的虛擬主機(jī)配置處,追加加粗行:
location / {
rewrite "^/admin/(+).htm$" /admin/index.php?$1.htm;
rewrite "^/(+).htm$" /index.php?$1.htm;
index index.html index.htm index.php;
root /data/wwwroot/xiuno.com;
}
然后重新啟動(dòng) nginx: service nginx restart
Apache:
vim /etc/httpd/conf/httpd.conf
Options Includes FollowSymLinks
AllowOverride All
Allow from All
NameVirtualHost *:80
ServerName domain.com
ServerAlias domain.com
DocumentRoot /data/wwwroot/domain.com/
DirectoryIndex index.html index.php index.htm
RewriteEngine on
RewriteRule ^/(+)\.htm$ /index.php?$1.htm
RewriteRule ^/admin/(+)\.htm$ /admin/index.php?$1.htm
Apache .htaccess
如果Appache 支持 .htaccess,那么可以編輯 .htaccess 文件放置于根目錄下:
RewriteEngine on
RewriteRule ^admin/(+)\.htm$ admin/index.php?$1.htm
RewriteRule ^(+)\.htm$ index.php?$1.htm
有站長測(cè)試發(fā)現(xiàn) Apache .htaccess 不需要加 /,這個(gè)可以自己嘗試下,路徑要對(duì)。
SAE環(huán)境,根目錄建立 config.yaml 文件:
appname: axiuno
version: 1
handle:
- rewrite: if ( !is_dir() && !is_file() && path ~ "admin/(.*\.htm)" ) goto "admin/index.php?%1"
- rewrite: if ( !is_dir() && !is_file() && path ~ "\.htm" ) goto "index.php?%1"