2_400_300.jpg

XiunoBBS 只需要一条规则:

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


Xiuno BBS 2.1 需要编辑 conf/conf.php,Xiuno BBS 3.0 不需要 1、2 步骤。

1. 编辑 conf/conf.php 中的 'urlrewrite' => 1, 
2. 清空 tmp 目录
3. 修改 Web Server 的 Rewrite 规则,以下为各种Web Server 的样例:

4. 重启 web server


Nginx:

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

 

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

         if (!-e $request_filename) {

                 rewrite  ^(.*)$  /index.php?s=$1  last;

        }

        index    index.html index.htm index.php;
        root     /data/wwwroot/xiuno.com;

 

然后重新启动 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

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

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

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


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


</IfModule>


Apache httpd.conf

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

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

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

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


RewriteRule ^/(.*)\.htm(.*)$ /index.php?$1.htm$2 [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 ~ "mobile/(.*.htm)" ) goto "mobile/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 ^/mobile(.*)\.htm(.*) /mobile/index.php?$1.htm$2 [L]
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 ^/mobile/(.*)\.htm(.*) /mobile/$1.htm$2 [L]

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/mobile/(.*)\.htm(.*)$ /mobile/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 :ISAPI_Rewrite3.zip


反人类的 IIS REWRITE!!!

syitian   1月前135

虚拟主机 设置好了,Apache/2,放在BBS下的设置

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

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

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

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


  • 完美在线   3月前

  • 123

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 ^/mobile(.*)\.htm(.*) /mobile/index.php?$1.htm$2 [L]
RewriteRule ^/admin(.*)\.htm(.*) /admin/index.php?$1.htm$2 [L]
RewriteRule ^(.*)\.htm(.*) /index.php?$1.htm$2 [L]


去掉7、8两行"/"就可以了


老大你真是坑,最后放置到BBS目录的规则写错了也不改一下,正确应该是
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^bbs/admin/(.*)\.htm(.*)$ /bbs/admin/index.php?$1.htm$2 [L]
RewriteRule ^bbs/mobile/(.*)\.htm(.*)$ /bbs/mobile/index.php?$1.htm$2 [L]
RewriteRule ^bbs/(.*)\.htm(.*)$ /bbs/index.php?$1.htm$2 [L]
</IfModule>

有人说不知道 rewrite 放哪里,我贴出来官方的一段:

[root@xiuno /]# cat /usr/local/nginx/conf/vhosts/bbs.xiuno.com.conf #xiuno.comserver {        listen    80;         server_name   bbs.xiuno.com;        access_log    /data/log/bbs.xiuno.com.access.log combined;        error_log     /data/log/bbs.xiuno.com.error.log crit;        location / {                 rewrite "^(.*)/(.+?).htm$" $1/index.php?$2.htm last;                if (!-e $request_filename) {                        rewrite  ^(.*)$  /index.php?s=$1  last;                }                index    index.html index.htm index.php;                root     /home/wwwroot/bbs.xiuno.com;        }


  • 设置Xiuno BBS URL-Rewrite(WINDOWS2008+IIS7.5伪静态设定)

  • 近日看到好多站长对WINDOWS伪静态设置一头雾水,现将亲测可用的提供给大家


  • 服务器空间环境

  • 操作系统:WINDOWS 2008 64位

  • Web Server:Microsoft-IIS/7.5

  • PHP:5.2.17

  • 数据库:mysql (5.1)


    IIS7.5环境下设置伪静态,需要设置放置三个伪静态文件web.config:


    1、根目录下:

    <?xml version="1.0" encoding="UTF-8"?>

    <configuration>

        <system.webServer>

            <rewrite>

                <rules>

                    <rule name="index" stopProcessing="true">

                        <match url="^(.*)\.htm$" ignoreCase="false" />

                        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">

                            <add input="{R:1}" pattern="^(upload|admin|mobile|xneditor)" ignoreCase="false" negate="true" />

                        </conditions>

                        <action type="Rewrite" url="index.php/{R:1}.htm" />

                    </rule>

                </rules>             

            </rewrite>

        </system.webServer>

    </configuration>


    2、mobile目录下:

    <?xml version="1.0" encoding="UTF-8"?>

    <configuration>

        <system.webServer>

            <rewrite>

                <rules>

                    <rule name="mobile" stopProcessing="true">

                        <match url="^(.*).htm$" ignoreCase="false" />

                        <conditions logicalGrouping="MatchAll">

                            <add input="{R:1}" pattern="^(index\.php)" ignoreCase="false" negate="true" />

                        </conditions>

                        <action type="Rewrite" url="index.php/{R:1}.htm" />

                    </rule>

                </rules>

            </rewrite>

        </system.webServer>

    </configuration>


    3、后台admin目录下:

    <?xml version="1.0" encoding="UTF-8"?>

    <configuration>

        <system.webServer>

            <rewrite>

                <rules>

                    <rule name="admin" stopProcessing="true">

                        <match url="^(.*).htm$" ignoreCase="false" />

                        <conditions logicalGrouping="MatchAll">

                            <add input="{R:1}" pattern="^(index\.php)" ignoreCase="false" negate="true" />

                        </conditions>

                        <action type="Rewrite" url="index.php/{R:1}.htm" />

                    </rule>

                </rules>

            </rewrite>

        </system.webServer>

    </configuration>


如果要开启自定义URL,那么 IIS 得设置为:

[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 ^(.*) /index.php?$1 [L]

iis 7.5 经过网友测试,追加此条后才能进入后台:
  <add input="{R:1}" pattern="^(admin)" ignoreCase="false" negate="true" />

Nginx只加

if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
}

lighttpd下用

                "^/admin/([^/]+).htm$" => "/admin/index.php?$1.htm",
                "^/([^/]+).htm$" => "/index.php?$1.htm",

测试成功

今天发现一个 WDCP(一套Linux下的虚拟主机管理软件)下启用 rewrite 的问题,总结下几个要点:

1. 只启用 apache 模式(内含 nginx, nginx+apache 其他模式)。

2.  添加rewrite 规则,名字叫:xiuno_apache.conf

3. 站点编辑,启用xiuno_apache.conf,内容(红色必须有):


      RewriteEngine on

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

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

      

4. 重启 web server



Эта статья взята из http://www.chieng.cn, воспроизведена, пожалуйста, укажите!

打赏 支付宝 微信