XiunoBBS4.0.4伪静态设置方法,包含Nginx、Apache、IIS、Caddy、SAE、WDCP

第一步:HTTP服务器设置
XiunoBBS 伪静态设置规则:将 .htm 转发到 index.php?.htm

Nginx
在nginx配置文件的server节点下新增如下内容:

location ~* \.(htm)$ {
        rewrite "^(.*)/(.+?).htm(.*?)$" $1/index.php?$2.htm$3 last;
    }

修改后重启nginx服务

Apache
如果Appache 支持 .htaccess,可以在网站根目录创建文件 .htaccess,内容如下:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*?)([^/]*)$ $1index.php?$2[QSA,PT,L]
</IfModule>

也可以修改httpd.conf,如果将规则直接放入 httpd.conf 则需要在前面加 /

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^(.*?)([^/]*)\.htm(.*)$ $1/index.php?$2.htm$3 [L]
</IfModule>

IIS
修改web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
 <rewrite>
 <rules>
 <rule name="xiuno">
 <match url="^((.*)/)?(.+).html$" />
 <action type="Rewrite" url="{R:1}\index.php?{R:2}.html" />
 </rule>
 </rules>
 </rewrite>
 </system.webServer>
</configuration>

Caddy

www.yourdomain.com

# Set this path to your site's directory.
root * /var/www

file_server

# Or serve a PHP site through php-fpm:
php_fastcgi localhost:9000

SAE
如果是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"

WDCP
WDCP是一套Linux下的虚拟主机管理软件,总结下几个要点:

只启用 apache 模式(内含 nginx, nginx+apache 其他模式)。
添加rewrite 规则,名字叫:xiuno_apache.conf
站点编辑,启用xiuno_apache.conf,内容:

RewriteEngine on
RewriteRule ^/admin/([^/]+)\.htm$ /admin/index.php?$1.htm [L]
RewriteRule ^/([^/]+)\.htm$ /index.php?$1.htm [L]

重启 web server

第二步:XiunoBBS网站配置
修改conf/conf.php,将url_rewrite_on 改成1,然后在后台清理缓存

相关文章

发表新评论