修罗程序伪静态设置web.config htaccess伪静态文件直接给大家提供(自丢网原创教程)

[复制链接]
查看6423 | 回复4 | 2019-3-8 17:57 | 显示全部楼层 |阅读模式
修罗程序伪静态设置web.config htaccess伪静态文件直接给大家提供(自丢网原创教程)

XiunoBBS 只需要一条规则:

将 *.htm* 转发到 index.php?*.htm* 即可。

Xiuno BBS 4.0  需要编辑 conf/conf.php

1. 编辑 'url_rewrite_on'=>1,
2. 清空 tmp 目录

Nginx:

打开 nginx 配置文件 /usr/local/nginx/conf/nginx.conf 找到对应的虚拟主机配置处,追加加粗行:

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

然后重新启动 nginx: service nginx restart

Apache:

vim /etc/httpd/conf/httpd.conf
<Directory d:/xiuno.com>
    Options FollowSymLinks ExecCGI Indexes
    AllowOverride all
    Order deny,allow
    Allow from all
    Satisfy all
</Directory>
NameVirtualHost *:80


Apache .htaccess

如果Appache 支持 .htaccess,那么可以编辑 .htaccess 文件放置于根目录下:

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

Apache httpd.conf

如果将规则直接放入 httpd.conf 则需要在前面加 / ,看来 Apache 也反人类:

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


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"


下面给大家提供直接拿来用的两个干货.htaccessweb.config

htaccess.zip (359 Bytes, 下载次数: 6, 售价: 1 丢币)
壹佰代刷网 | 2019-3-8 18:42 | 显示全部楼层
很厉害 但是没看懂
qq2501 | 2019-4-29 20:38 | 显示全部楼层
应该下载哪一个
zhangmi | 2019-4-29 21:24 | 显示全部楼层
是不是把.htaccess的内容编辑为
<IfModule mod_rewrite.c>
RewriteEngine on
# Apache 2.4
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*?)([^/]*)$ $1index.php?$2 [QSA,PT,L]
# Apache other
#RewriteRule ^(.*?)([^/]*)\.htm(.*)$ $1/index.php?$2.htm$3 [L]
</IfModule>
admin | 2019-4-30 06:57 | 显示全部楼层
zhangmi 发表于 2019-4-29 13:24
是不是把.htaccess的内容编辑为

RewriteEngine on

对的
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

UID
1
贡献
387
丢币
38902
主题
4607
回帖
116
注册时间
2018-9-25
最后登录
2024-4-16