> For the complete documentation index, see [llms.txt](https://qx.atlucky.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://qx.atlucky.me/shi-yong-fang-fa/pei-zhi-wen-jian-xiang-jie/zhong-xie-rewrite/rewrite_local.md).

# rewrite\_local

关于重写的介绍见上一章节[重写\[rewrite\]](/shi-yong-fang-fa/pei-zhi-wen-jian-xiang-jie/zhong-xie-rewrite.md)。本章节只介绍如何使用本地重写。

{% hint style="warning" %}
此种方法只能自己手动更新，因此不建议新手小白添加。
{% endhint %}

因为重写（rewrite）涉及的类型比较多，很多时候会需要搭配mitm使用，正常的步骤就是根据需要添加的内容，在设置->重写规则中按照正确的类型进行添加，然后在mitm->主机名中添加对应的主机名。（推荐）这里简单的以一个掌上生活去广告为例，图文演示一下添加过程：

去广告来源：<https://t.me/Aa28413761/1319>

内容：

```
#投稿 #掌上生活 去开屏广告更新
^https:\/\/mbasecc\.bas\.cmbchina\.com\/Edge\/api\/mlife\.clientface\.clientservice\.api\.advertiseService\/preCacheAdvertiseSec url reject-dict
hostname = mbasecc.bas.cmbchina.com
```

将`^https:\/\/mbasecc\.bas\.cmbchina\.com\/Edge\/api\/mlife\.clientface\.clientservice\.api\.advertiseService\/preCacheAdvertiseSec` 这部分添加到重写规则的用以匹配的URL内，选择类型为`reject-dict`，在mitm部分的主机名中添加：`mbasecc.bas.cmbchina.com`

<figure><img src="/files/aJEYnS8EMpYbFJBlBWTe" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
如果有类似的配置都是采用相同的添加方法，url这个之前词的是匹配正则，之后的是类型
{% endhint %}

<figure><img src="/files/tWipVtrDJdJG8rJ34eAo" alt=""><figcaption><p>简单的例子</p></figcaption></figure>

如果熟悉的话也可以通过文本模式分别粘贴到\[rewrite\_local]和\[mitm]字段内（不推荐）

见下图示例，切记主机名只复制hostname后面的那部分进去，和之前的用英文逗号隔开。

<figure><img src="/files/pBWWgKh1Jmf3nguADWZj" alt=""><figcaption><p>hostneame字段只复制主机名进来就行了</p></figcaption></figure>

错误的例子见：[错误示范](/shi-yong-fang-fa/pei-zhi-wen-jian-xiang-jie/mitm.md#cuo-wu-shi-fan)

在配置片段中也可以通过文本的方式添加，方法见下图示例：

配置片段->重写->粘贴内容保存

<figure><img src="/files/QLB9exOjK728eYZxF4Re" alt=""><figcaption></figcaption></figure>

可以保留默认自动生成的名字，也可自己取个名字，记得**保留`.snippet`**&#x540E;缀

<figure><img src="/files/6otAuoqQk0Uv9DN8rapQ" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
通过配置片段添加的引用资源是保存在配置文件的\[rewrite\_remote]字段下的

UI界面中显示在重写的规则资源-引用资源中。
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://qx.atlucky.me/shi-yong-fang-fa/pei-zhi-wen-jian-xiang-jie/zhong-xie-rewrite/rewrite_local.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
