Java小强个人技术博客站点    手机版
当前位置: 首页 >> 服务器 >> emlog4.0 5.0伪静态规则 iis / nginx

emlog4.0 5.0伪静态规则 iis / nginx

73160 服务器 | 2015-1-27

IIS6:(iis6主机请联系主机商修改规则,部分主机支持httpd.ini,请将下列代码保存为httpd.ini或者下载附件中的httpd.ini上传到博客根目录)

[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteRule /robots.txt(.*) /robots.txt$1 [L]
RewriteRule /rss.php(.*) /rss.php$1 [L]
RewriteRule /tb.php(.*) /tb.php$1 [L]
RewriteRule /favicon.ico /favicon.ico [L]
RewriteRule /xmlrpc.php(.*) /xmlrpc.php$1 [L] 
RewriteRule /wlwmanifest.xml /wlwmanifest.xml [L] 
RewriteRule /(t|m)$ /$1/ [R]
RewriteRule /(admin|content|include|t|m)/(.*) /$1/$2 [L]
RewriteRule /install.php(.*) /install.php$1 [L]
RewriteRule /emlog_toolkit.php(.*) /emlog_toolkit.php$1 [L]
RewriteRule /up(\d.\d.\d)to(\d.\d.\d).php(.*) /up$1to$2.php$3 [L]
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]


支持.htaccess的IIS6服务器规则:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [L]


【注】关于IIS6规则说明:由于IIS6不支持.htaccess的一些判断规则,因此只能事先处理一些会被正常访问的目录或者文件。有些地方可能需要做修改:

1、如果你有其他非emlog文件,因为添加如上规则而不能正常访问,要想使它们能正常访问的,则添加一条规则在第5行后面,参考第五行

RewriteRule /rss.php(.*) /rss.php$1 [L]


将rss.php修改为你要访问的文件即可

如果你有其他非emlog目录,因为添加如上规则而不能正常访问,要想使它们能正常访问的,则参考第10、11行,将目录添加进来(用|隔开目录):

RewriteRule /(t|m|admin)$ /$1/ [R] 
RewriteRule /(admin|content|include|t|m)/(.*) /$1/$2 [L]


2、如果你的博客在子目录,那么需要将所有目录都改为子目录的,比如你的博客在emlog目录下,那么规则如下:

[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteRule /emlog/rss.php(.*) /emlog/rss.php$1 [L]
RewriteRule /emlog/tb.php(.*) /emlog/tb.php$1 [L]
RewriteRule /emlog/favicon.ico /emlog/favicon.ico [L]
RewriteRule /emlog/xmlrpc.php(.*) /emlog/xmlrpc.php$1 [L] 
RewriteRule /emlog/wlwmanifest.xml /emlog/wlwmanifest.xml [L] 
RewriteRule /emlog/(t|m)$ /emlog/$1/ [R]
RewriteRule /emlog/(admin|content|include|t|m)/(.*) /emlog/$1/$2 [L]
RewriteRule /emlog/install.php(.*) /emlog/install.php$1 [L]
RewriteRule /emlog/emlog_toolkit.php(.*) /emlog/emlog_toolkit.php$1 [L]
RewriteRule /emlog/up(\d.\d.\d)to(\d.\d.\d).php(.*) /emlog/up$1to$2.php$3 [L]
RewriteRule ^/emlog/$ /emlog/index.php [L]
RewriteRule /emlog/(.*) /emlog/index.php/$1 [L]


nginx:(nginx主机请联系主机商更改规则,部分主机可能支持自定义规则)

location / {
        index index.php index.html;
        if (!-e $request_filename)
        {
                rewrite ^/(.+)$ /index.php last;
        }
}


IIS7/7.5 规则

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="emlog 4.0.1 for IIS7.5" stopProcessing="true">
                    <match url="." ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>


伪静态是相对真实静态来讲的,通常我们为了增强搜索引擎的友好面,都将文章内容生成静态页面,但是有的朋友为了实时的显示一些信息。或者还想运用动态脚本解决一些问题。不能用静态的方式来展示网站内容。但是这就损失了对搜索引擎的友好面。怎么样在两者之间找个中间方法呢,这就产生了伪静态技术。就是展示出来的是以html一类的静态页面形式,但其实是用ASP一类的动态脚本来处理的。

用IIS的404错误处理机制来实现的。这个比rewrite技术要灵活的多。

首先,设置站点属性-自定义错误,找到HTTP错误404,然后编辑属性->消息类型选中URL->URL填入“/index.asp”,或您的错误处理页面。

这样,比如用户或蜘蛛访问http://网址XXX/12345.html时(12345为文章在数据库的ID).由于这些页面不存在,所以触发了404错误。转向了index.asp

推荐您阅读更多有关于“ 伪静态 emlog iis nginx ”的文章

上一篇:PHP curl扩展开启的步骤 下一篇:JS 图片上传预览

猜你喜欢

发表评论: