ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

如何设置Xiuno BBS URL-Rewrite(伪静态设定)

2021-08-07 09:06:05  阅读:209  来源: 互联网

标签:RewriteRule IIS Rewrite URL index htm Xiuno php


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"


IIS: 
1. 下载 Rewrite.zip

2. 解压到 c:\Rewrite

3. 在IIS的Isapi上添加这个筛选器, 筛选器名称Rewrite,可执行文件选择 Rewrite.dll

4. 重新启动IIS

5. httpd.ini 是配置文件,如果您了解Rewrite 规则,可以直接对其进行编辑,以下为包内设置好的Xiuno BBS的规则:

[ISAPI_Rewrite]

# 3600 = 1 hour

CacheClockRate 3600

RepeatLimit 32

#RewriteRule .*\.(?:gif|jpg|png|css|js|txt|jpeg|swf|flv) $0 [I,L] 

#RewriteRule /httpd(?:\.ini|\.parse\.errors) / [F,I,O]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^/admin(.*)\.htm(.*) /admin/index.php?$1.htm$2 [L]
RewriteRule ^(.*)\.htm(.*) /index.php?$1.htm$2 [L]


另外一种 IIS Rewrite:

[ISAPI_Rewrite]

# 3600 = 1 hour

CacheClockRate 3600

RepeatLimit 32

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^/admin/(.*)\.htm(.*) /admin/$1.htm$2 [L]

RewriteRule ^(.*)\.htm(.*)$ /$1.htm$2 [L]



如果要放到目录下,比如 bbs 目录,在 rewrite 规则前面加上目录即可,比如 apache .htaccess:
<IfModule mod_rewrite.c>

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^bbs/admin/(.*)\.htm(.*)$ /admin/index.php?$1.htm$2 [L]

RewriteRule ^bbs/(.*)\.htm(.*)$ /index.php?$1.htm$2 [L]

</IfModule>


IIS 的高版本配置方法:

IIS 的高版本配置方法1:http://bbs.xiuno.com/thread-9008.htm

IIS 的高版本配置方法2:http://bbs.xiuno.com/thread-9411.htm

IIS 的详细配置方法请参看:http://my.oschina.net/lyx2012/blog/60198


IIS Rewrite 支持 Apache .htaccess   


反人类的 IIS REWRITE!!!

标签:RewriteRule,IIS,Rewrite,URL,index,htm,Xiuno,php
来源: https://blog.csdn.net/a924282761/article/details/119476470

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有