admin 发表于 2021-11-8 09:12:06

①文章标签 伪静态版IIS/APACHE/Nginx伪静态规则

伪静态规则,放在其它DZ规则的上面,如:thread规则这一行上面

# IIS/APACHE Web Server 1                                                         
RewriteRule ^(.*)/tag(_(+))?(/|\.html)?$ $1/plugin\.php\?id=onexin_tags&page=$3&%1
RewriteRule ^(.*)/tag-(\d+)(-(\d+))?(/|\.html)?$ $1/plugin\.php\?id=onexin_tags&tagid=$2&page=$4&%1
RewriteRule ^(.*)/tag/([^\/\.]+)(/(\d+))?(/|\.html)?$ $1/plugin\.php\?id=onexin_tags&tagname=$2&page=$4&%1

# IIS/APACHE Web Server 2                                                         
RewriteRule ^tag(_(+))?(/|\.html)?$ plugin.php?id=onexin_tags&page=$2&%1      
RewriteRule ^tag-(\d+)(-(\d+))?(/|\.html)?$ plugin.php?id=onexin_tags&tagid=$1&page=$3&%1         
RewriteRule ^tag/([^\/\.]+)(/(\d+))?(/|\.html)?$ plugin.php?id=onexin_tags&tagname=$1&page=$3&%1

# Nginx Web Server            
rewrite ^([^\.]*)/tag(_(+))?(/|\.html)?$ $1/plugin.php?id=onexin_tags&page=$3 last;
rewrite ^([^\.]*)/tag-(\d+)(-(\d+))?(/|\.html)?$ $1/plugin.php?id=onexin_tags&tagid=$2&page=$4 last;
rewrite ^([^\.]*)/tag/([^\/\.]+)(/(\d+))?(/|\.html)?$ $1/plugin.php?id=onexin_tags&tagname=$2&page=$4 last;

# IIS 7.x及以上 Web Server(独立主机用户)
<rule name="onexin_tag_1">
<match url="^(.*/)*tag(_(+))?(/|\.html)?$" />
<action type="Rewrite" url="{R:1}/plugin.php\?id=onexin_tags&amp;page={R:3}" />
</rule>
<rule name="onexin_tag_2">
<match url="^(.*/)*tag-(\d+)(-(\d+))?(/|\.html)?$" />
<action type="Rewrite" url="{R:1}/plugin.php\?id=onexin_tags&amp;tagid={R:2}&amp;page={R:4}" />
</rule>
<rule name="onexin_tag_3">
<match url="^(.*/)*tag/([^\/\.]+)(/(\d+))?(/|\.html)?$" />
<action type="Rewrite" url="{R:1}/plugin.php\?id=onexin_tags&amp;tagname={R:2}&amp;page={R:4}" />
</rule>

=================网址说明=============================
旧规则
http://demo.onexin.com/tag.html
http://demo.onexin.com/tag-110.html

新规则(推荐目录化写法)
http://demo.onexin.com/tag/
http://demo.onexin.com/tag/影响力/

GM-爱好者 发表于 2021-11-30 11:41:37


我看不错噢 谢谢楼主!dz插件网越来越好!

Discuz智能体 发表于 2025-3-21 08:20:34

根据你提供的伪静态规则,以下是对这些规则的详细解释和优化建议:

### 1. **IIS/APACHE Web Server 1**
RewriteRule ^(.*)/tag(_(+))?(/|\.html)?$ $1/plugin\.php\?id=onexin_tags&page=$3&%1
RewriteRule ^(.*)/tag-(\d+)(-(\d+))?(/|\.html)?$ $1/plugin\.php\?id=onexin_tags&tagid=$2&page=$4&%1
RewriteRule ^(.*)/tag/(+)(/(\d+))?(/|\.html)?$ $1/plugin\.php\?id=onexin_tags&tagname=$2&page=$4&%1

- **第一条规则**:匹配形如 `http://demo.onexin.com/tag.html` 或 `http://demo.onexin.com/tag_2.html` 的URL,并将其重写为 `plugin.php?id=onexin_tags&page=2`。
- **第二条规则**:匹配形如 `http://demo.onexin.com/tag-110.html` 或 `http://demo.onexin.com/tag-110-2.html` 的URL,并将其重写为 `plugin.php?id=onexin_tags&tagid=110&page=2`。
- **第三条规则**:匹配形如 `http://demo.onexin.com/tag/影响力/` 或 `http://demo.onexin.com/tag/影响力/2.html` 的URL,并将其重写为 `plugin.php?id=onexin_tags&tagname=影响力&page=2`。

### 2. **IIS/APACHE Web Server 2**
RewriteRule ^tag(_(+))?(/|\.html)?$ plugin.php?id=onexin_tags&page=$2&%1      
RewriteRule ^tag-(\d+)(-(\d+))?(/|\.html)?$ plugin.php?id=onexin_tags&tagid=$1&page=$3&%1         
RewriteRule ^tag/(+)(/(\d+))?(/|\.html)?$ plugin.php?id=onexin_tags&tagname=$1&page=$3&%1

- **第一条规则**:匹配形如 `http://demo.onexin.com/tag.html` 或 `http://demo.onexin.com/tag_2.html` 的URL,并将其重写为 `plugin.php?id=onexin_tags&page=2`。
- **第二条规则**:匹配形如 `http://demo.onexin.com/tag-110.html` 或 `http://demo.onexin.com/tag-110-2.html` 的URL,并将其重写为 `plugin.php?id=onexin_tags&tagid=110&page=2`。
- **第三条规则**:匹配形如 `http://demo.onexin.com/tag/影响力/` 或 `http://demo.onexin.com/tag/影响力/2.html` 的URL,并将其重写为 `plugin.php?id=onexin_tags&tagname=影响力&page=2`。

### 3. **Nginx Web Server**
rewrite ^(*)/tag(_(+))?(/|\.html)?$ $1/plugin.php?id=onexin_tags&page=$3 last;
rewrite ^(*)/tag-(\d+)(-(\d+))?(/|\.html)?$ $1/plugin.php?id=onexin_tags&tagid=$2&page=$4 last;
rewrite ^(*)/tag/(+)(/(\d+))?(/|\.html)?$ $1/plugin.php?id=onexin_tags&tagname=$2&page=$4 last;

- **第一条规则**:匹配形如 `http://demo.onexin.com/tag.html` 或 `http://demo.onexin.com/tag_2.html` 的URL,并将其重写为 `plugin.php?id=onexin_tags&page=2`。
- **第二条规则**:匹配形如 `http://demo.onexin.com/tag-110.html` 或 `http://demo.onexin.com/tag-110-2.html` 的URL,并将其重写为 `plugin.php?id=onexin_tags&tagid=110&page=2`。
- **第三条规则**:匹配形如 `http://demo.onexin.com/tag/影响力/` 或 `http://demo.onexin.com/tag/影响力/2.html` 的URL,并将其重写为 `plugin.php?id=onexin_tags&tagname=影响力&page=2`。

### 4. **IIS 7.x及以上 Web Server(独立主机用户)**
对于IIS 7.x及以上版本,你可以使用以下规则:

<rule name="Tag Rule 1" stopProcessing="true">
    <match url="^(.*)/tag(_(+))?(/|\.html)?$" />
    <action type="Rewrite" url="{R:1}/plugin.php?id=onexin_tags&page={R:3}&{QUERY_STRING}" />
</rule>
<rule name="Tag Rule 2" stopProcessing="true">
    <match url="^(.*)/tag-(\d+)(-(\d+))?(/|\.html)?$" />
    <action type="Rewrite" url="{R:1}/plugin.php?id=onexin_tags&tagid={R:2}&page={R:4}&{QUERY_STRING}" />
</rule>
<rule name="Tag Rule 3" stopProcessing="true">
    <match url="^(.*)/tag/(+)(/(\d+))?(/|\.html)?$" />
    <action type="Rewrite" url="{R:1}/plugin.php?id=onexin_tags&tagname={R:2}&page={R:4}&{QUERY_STRING}" />
</rule>

### 5. **网址说明**
- **旧规则**:
- `http://demo.onexin.com/tag.html`
- `http://demo.onexin.com/tag-110.html`

- **新规则(推荐目录化写法)**:
- `http://demo.onexin.com/tag/`
- `http://demo.onexin.com/tag/影响力/`

### 6. **优化建议**
- **URL规范化**:建议统一使用目录化的URL结构,如 `http://demo.onexin.com/tag/影响力/`,这样更符合SEO优化。
- **缓存策略**:可以考虑为这些URL设置缓存策略,以提高页面加载速度。
- **错误处理**:确保在URL参数错误或缺失时,能够正确处理并返回404页面或其他友好提示。

如果你有更多问题或需要进一步的帮助,请随时联系我!
-- 本回答由 人工智能 AI智能体 生成,内容仅供参考,请仔细甄别。
页: [1]
查看完整版本: ①文章标签 伪静态版IIS/APACHE/Nginx伪静态规则