Wordpress 410在htaccess中重写规则

Wordpress 410在htaccess中重写规则,wordpress,apache,.htaccess,mod-rewrite,Wordpress,Apache,.htaccess,Mod Rewrite,我似乎无法从wordpress安装中获得410响应。我一直用404代替。我做错了什么?我搜索了不少帖子,似乎都指向相同的代码,或者由于cPanel错误,需要一个errordocument410默认值 # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f Re

我似乎无法从wordpress安装中获得410响应。我一直用404代替。我做错了什么?我搜索了不少帖子,似乎都指向相同的代码,或者由于cPanel错误,需要一个
errordocument410默认值

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#### 410 responses ####
RewriteRule ^test/?$ [G,L]
#### end 410 responses ####

RewriteRule . /index.php [L]
</IfModule>
# END WordPress

ErrorDocument 410 default
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
####410份答复####
重写规则^test/?$[G,L]
####完410份答复####
重写规则/index.php[L]
#结束WordPress
ErrorDocument 410默认值
还尝试了评论中建议的方法,但未成功:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#### 410 responses ####
RewriteRule ^test/?$ [R=410,L]
#### end 410 responses ####

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
#开始WordPress
重新启动发动机
重写基/
####410份答复####
重写规则^test/?$[R=410,L]
####完410份答复####
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress

这是您所需要的全部:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^test/?$ - [R=410,L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
#开始WordPress
重新启动发动机
重写基/
重写规则^test/?$-[R=410,L]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress

我在你的代码中看到的主要问题是,它缺少一个破折号
-
来定义要采取的行动,以及它在你先前发布的
.htaccess
中的早期位置。我使用的是Chrome的开发工具。我最初是在
RewriteBase/
之后直接使用的,结果也是一样的。我根据一些其他帖子把它移到request_filename行下面,看看它是否重要。我知道秩序很重要,但我承认我在这里是绿色的。我在发布最后一条评论之前就试过了。不幸的是,仍然没有骰子。我将在上面添加它来显示代码,以确保我正确地遵循您的方向。这样做了。短跑。该死。这么简单。也适用于[G,L]。就是那个冲刺。非常感谢@Veo我只是更喜欢使用状态码,这样我就可以确定它在做什么,因为有这么多带有单个字母的标志,很高兴它为您工作:)