• 首页
  • 搜索
  • 夜间模式
    ©2026  大白蚁的生活碎碎念 Theme by OneBlog

    大白蚁的生活碎碎念博客

    搜索
    标签
    # 随笔 # 数据库 # typecho # Linux # teamspeak
  • 首页>
  • 学习>
  • 正文
  • Typecho 伪静态规则

    2023年07月10日 2 阅读 0 评论 2841 字

    Linux Apache 环境 (.htaccess):

    <IfModule mod_rewrite.c>
    RewriteEngine On
    # 下面是在根目录,文件夹要修改路径
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
    </IfModule>

    Linux Apache 环境(Nginx):

    location / {
    index index.html index.php;
    if (-f $request_filename/index.html) {
    rewrite (.*) $1/index.html break;
    }
    if (-f $request_filename/index.php) {
    rewrite (.*) $1/index.php;
    }
    if (!-f $request_filename) {
    rewrite (.*) /index.php;
    }
    }

    Windows IIS 伪静态 (httpd.ini):

    [ISAPI_Rewrite]
    # 3600 = 1 hour
    CacheClockRate 3600
    RepeatLimit 32
    # 中文tag解决
    RewriteRule /tag/(.*) /index\.php\?tag=$1
    # sitemapxml
    RewriteRule /sitemap.xml /sitemap.xml [L]
    RewriteRule /favicon.ico /favicon.ico [L]
    # 内容页
    RewriteRule /(.*).html /index.php/$1.html [L]
    # 评论
    RewriteRule /(.*)/comment /index.php/$1/comment [L]
    # 分类页
    RewriteRule /category/(.*) /index.php/category/$1 [L]
    # 分页
    RewriteRule /page/(.*) /index.php/page/$1 [L]
    # 搜索页
    RewriteRule /search/(.*) /index.php/search/$1 [L]
    # feed
    RewriteRule /feed/(.*) /index.php/feed/$1 [L]
    # 日期归档
    RewriteRule /2(.*) /index.php/2$1 [L]
    # 上传图片等
    RewriteRule /action(.*) /index.php/action$1 [L]

    Typecho的IIS伪静态规则web.config

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="typecho" stopProcessing="true">
                        <match url="^(.*)$" ignoreCase="false" />
                        <conditions logicalGrouping="MatchAll">
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>

    nginx 配置

    server {
            listen          80;
            server_name     yourdomain.com;
            root            /home/yourdomain/www/;
            index           index.html index.htm index.php;
    
            if (!-e $request_filename) {
                rewrite ^(.*)$ /index.php$1 last;
            }
    
            location ~ .*\.php(\/.*)*$ {
                include fastcgi.conf;
                fastcgi_pass  127.0.0.1:9000;
            }
    
            access_log logs/yourdomain.log combined;
        }

    apache 配置

    <IfModule mod_rewrite.c>
        RewriteEngine On
    
        RewriteBase /
    
        RewriteCond %{REQUEST_FILENAME} !-f
    
        RewriteCond %{REQUEST_FILENAME} !-d
    
        RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
    
    </IfModule>
    本文著作权归作者 [ 大白蚁 ] 享有,未经作者书面授权,禁止转载,封面图片来源于 [ 互联网 ] ,本文仅供个人学习、研究和欣赏使用。如有异议,请联系博主及时处理。
    — END —
    首页
    Copyright©2026  All Rights Reserved.  Load:0.015 s
    Theme by OneBlog V3.6.5
    夜间模式

    开源不易,请尊重作者版权,保留基本的版权信息。