htaccess WordPress无法正常工作



我正在使用更新的WP,我正在尝试将旧URL重定向到新URL:

Redirect 301 /es/ http://www.example.com
Redirect 301 /es/tienda/ http://www.example.com
Redirect 301 /es/categoria-producto/quillas/center http://www.example.com/categoria/quillas-single/

这就是我在浏览器中得到的:

如果我尝试访问第一个URL,我将重定向到:

http://www.example.comtienda/

是的,它缺少斜线。

,如果我尝试访问另一个URL,我将重定向到:

http://www.example.com/categoria-producto/quillas/center/

是404 ...

所以,我迁移了网站思考服务器错误,但问题仍然存在...

我在做什么错?

Redirect 301 /es/ http://www.example.com
Redirect 301 /es/tienda/ http://www.example.com
Redirect 301 /es/categoria-producto/quillas/center http://www.example.com/categoria/quillas-single/

由于MOD_ALIAS Redirect指令是前缀匹配,因此您需要扭转这些指令。但是您缺少目标URL末端的斜线,因此这就是为什么缺少斜线的原因。因此,例如:

Redirect 301 /es/categoria-producto/quillas/center/ http://www.example.com/categoria/quillas-single/
Redirect 301 /es/tienda/ http://www.example.com/
Redirect 301 /es/ http://www.example.com/

如果您在源URL上有斜线,则应在目标上包含斜线。

但是,由于这是一个WordPress站点,因此您应该使用mod_rewrite。例如,在您现有的WP指令之前:

RewriteRule ^es/categoria-producto/quillas/center$ /categoria/quillas-single/ [R=301,L]
RewriteRule ^es/tienda/$ / [R=301,L]
RewriteRule ^es/$ / [R=301,L]

在这种情况下,指令的顺序无关紧要。

最新更新