1. 编辑 conf/conf.php
找到 'urlrewrite' => 0, 修改为:
'urlrewrite' => 1,
2. 清空 tmp 目录
3. 修改 Web Server 的 Rewrite 规则,以下为各种Web Server 的样例:
其实很简单,就是将 xxx.htm 转发到 index.php?xxx.htm
Nginx:
打开 nginx 配置文件 /usr/local/nginx/conf/nginx.conf 找到对应的虚拟主机配置处,追加加粗行:
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;
}
然后重新启动 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
有站长测试发现 Apache .htaccess 不需要加 /,这个可以自己尝试下,路径要对。
SAE环境,根目录建立 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"
