2026.6.27号后的程序包 使用这个伪静态

} !-d
    RewriteRule ^(header|footer|copyright|ad)\.php$ includes/$1.php [L,QSA]

    # ===== SEO 伪静态 =====
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^thread/([0-9]+)\.html$ pages/thread.php?id=$1 [L,QSA]
    RewriteRule ^forum/([0-9]+)\.html$ pages/forum.php?id=$1 [L,QSA]
    RewriteRule ^user/([0-9]+)\.html$ pages/user.php?id=$1 [L,QSA]
    RewriteRule ^post\.html$ pages/post.php [L,QSA]
    RewriteRule ^search\.html$ pages/search.php [L,QSA]
    RewriteRule ^login\.html$ login.php [L,QSA]
    RewriteRule ^register\.html$ register.php [L,QSA]
    RewriteRule ^sitemap\.xml$ sitemap.xml [L]
</IfModule>

# 安全:拒绝敏感文件
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|sql|bak)$">
    Require all denied
</FilesMatch>

# 禁止子目录中的 PHP 脚本被执行
<Directory "uploads">
    <FilesMatch "\.(php|php3|php4|php5|phtml)$">
        Require all denied
    </FilesMatch>
</Directory>
<Directory "data">
    <FilesMatch "\.(php|php3|php4|php5|phtml)$">
        Require all denied
    </FilesMatch>
</Directory>
<Directory "cache">
    <FilesMatch "\.(php|php3|php4|php5|phtml)$">
        Require all denied
    </FilesMatch>
</Directory>
<Directory "includes">
    <FilesMatch "\.php$">
        Require all denied
    </FilesMatch>
</Directory>

# 静态资源缓存
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/webp "access plus 1 month"
    ExpiresByType image/svg+xml "access plus 1 month"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType application/javascript "access plus 1 week"
</IfModule>

# 字符集
AddDefaultCharset UTF-8

四、IIS(web.config)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <defaultDocument>
      <files>
        <clear />
        <add value="index.php" />
        <add value="index.html" />
      </files>
    </defaultDocument>

    <rewrite>
      <rules>
        <!-- 用户页 -> pages/ -->
        <rule name="Lume Pages" stopProcessing="true">
          <match url="^(forum|post|thread|search|profile|user|signin|rankings|drafts|messages|notifications|recharge|uid_shop|uid_change|vip|jail|captcha|edit_thread)\.php$" />
          <action type="Rewrite" url="pages/{R:1}.php" appendQueryString="true" />
        </rule>

        <!-- AJAX -> api/ -->
        <rule name="Lume Ajax" stopProcessing="true">
          <match url="^ajax_(.+)\.php$" />
          <action type="Rewrite" url="api/ajax_{R:1}.php" appendQueryString="true" />
        </rule>
        <rule name="Lume Collector" stopProcessing="true">
          <match url="^collector_api\.php$" />
          <action type="Rewrite" url="api/collector_api.php" appendQueryString="true" />
        </rule>

        <!-- 操作处理 -> actions/ -->
        <rule name="Lume Actions" stopProcessing="true">
          <match url="^(reply|moderator_action|pin_post|move_thread|delete_attachment|thread_pay|oauth_callback|download)\.php$" />
          <action type="Rewrite" url="actions/{R:1}.php" appendQueryString="true" />
        </rule>

        <!-- includes 组件 -> includes/ -->
        <rule name="Lume Includes" stopProcessing="true">
          <match url="^(header|footer|copyright|ad)\.php$" />
          <action type="Rewrite" url="includes/{R:1}.php" appendQueryString="true" />
        </rule>

        <!-- SEO 伪静态 -->
        <rule name="Lume Thread SEO" stopProcessing="true">
          <match url="^thread/([0-9]+)\.html$" />
          <action type="Rewrite" url="pages/thread.php?id={R:1}" appendQueryString="true" />
        </rule>
        <rule name="Lume Forum SEO" stopProcessing="true">
          <match url="^forum/([0-9]+)\.html$" />
          <action type="Rewrite" url="pages/forum.php?id={R:1}" appendQueryString="true" />
        </rule>
1 2

回复 1

倒序
管理员
活跃路人
如果觉得不好复制,下载下面的附件。里面好复制点。也更加详细
预打造一款,清爽、简洁、干净、一目了然、安全、高效、低负载的新概念纯论坛程序
登录后回复