【问题标题】:.htaccess file RewriteRule appends %25s to URL creating 404 errors.htaccess 文件 RewriteRule 将 %25s 附加到 URL 创建 404 错误
【发布时间】:2021-09-04 16:00:54
【问题描述】:

去年我更改了 Wordpress 博客上的永久链接结构。它似乎没有引起任何问题,旧 URL 具有永久 301 重定向。

不过,在运行 Moz 网站爬网后,我注意到一组 404 错误。原始链接仍在重定向到新链接,但 Moz 检测到 %25s 被附加到旧 URL 和新 URL,从而产生这些错误。

我假设这是我的重写规则的问题,但我不确定在哪里。任何帮助将不胜感激。

RewriteRule ([0-9]{4})\/([0-9]{2})\/([0-9]{2})\/(.*) https://letsprint3d.net/$4 [R=301,L]

### bunch of LiteSpeed Cache lines ###

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

【问题讨论】:

    标签: wordpress .htaccess mod-rewrite url-rewriting http-status-code-404


    【解决方案1】:

    您可以使用以下规则从 URL 中删除结尾的 %25s。只需放在您的 htaccess 顶部或 WordPress 规则之前。

    RewriteEngine on
    RewriteCond %{THE_REQUEST} /([^%25s]+)/\%25s
    RewriteRule .+ https://example.com/%1 [L,R=301]
    

    【讨论】:

    • 这不是问题的答案,是吗?问题询问“%25s”来自哪里以及如何防止它。不是怎么接受,后来又删了。
    猜你喜欢
    • 1970-01-01
    • 2015-06-25
    • 2018-06-18
    • 1970-01-01
    • 2022-12-10
    • 2015-08-22
    • 2023-03-03
    • 2015-09-28
    • 1970-01-01
    相关资源
    最近更新 更多