1

我正在尝试将网站的所有 EN 页面设置为状态码 410。 URL 如下所示:

https://example.com/en/terms-and-conditions/
https://example.com/en/sitemap/
https://example.com/en/category/page-1/
https://example.com/en/category/page-2/
https://example.com/en/category/page-3/subpage-1/

我尝试了不同的方法,但都没有奏效:

RewriteEngine On
RewriteRule ^/en(/.*)?$  - [G,NC]

这也不起作用:

RewriteEngine On
RewriteRule ^/en(.*)$ - [NC,R=410,L]

我究竟做错了什么?

4

1 回答 1

2

在 URL 路径中使用重写规则时,.htaccess不会以它开头,/因为那是重写规则的当前“基础”。这与.conf在路径确实/.

我建议通过将起始斜杠设为可选来编写可在任一位置使用的规则。您只需要?在起始斜杠后添加一个:

RewriteEngine On
RewriteRule ^/?en(/.*)?$  - [G,NC]
于 2022-02-26T12:54:20.333 回答