Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 301从特定的.html页面重定向到新的永久链接结构失败_Wordpress_.htaccess_Redirect_Permalinks - Fatal编程技术网

Wordpress 301从特定的.html页面重定向到新的永久链接结构失败

Wordpress 301从特定的.html页面重定向到新的永久链接结构失败,wordpress,.htaccess,redirect,permalinks,Wordpress,.htaccess,Redirect,Permalinks,我已经在线搜索了一个多小时,试图找出我的.htaccess文件没有按预期工作的原因,但是所有关于.htaccess的文档和问题似乎都表明一切都应该正常。我现在正在使用wordpress网站,需要将一些指向*.html文件的旧链接重定向到新的永久链接(一个接一个,因为命名约定已经完全改变)。因此,我的.htaccess文件如下所示: # Redirects for old URLs redirect 301 /contact_us http://rpcdev.thisisforge.com/con

我已经在线搜索了一个多小时,试图找出我的.htaccess文件没有按预期工作的原因,但是所有关于.htaccess的文档和问题似乎都表明一切都应该正常。我现在正在使用wordpress网站,需要将一些指向*.html文件的旧链接重定向到新的永久链接(一个接一个,因为命名约定已经完全改变)。因此,我的.htaccess文件如下所示:

# Redirects for old URLs
redirect 301 /contact_us http://rpcdev.thisisforge.com/contact/
redirect 301 /about_us http://rpcdev.thisisforge.com/about/
redirect 301 /clients http://rpcdev.thisisforge.com/work/
redirect 301 /clients/event.html http://rpcdev.thisisforge.com/work/event-retail-design/
redirect 301 /clients/identity.html http://rpcdev.thisisforge.com/work/identity-branding/
redirect 301 /clients/web.html http://rpcdev.thisisforge.com/work/web-design/
redirect 301 /clients/corp_lit.html http://rpcdev.thisisforge.com/work/brochures-publications/

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
#为旧URL重定向
重定向301/联系我们http://rpcdev.thisisforge.com/contact/
重定向301/关于我们http://rpcdev.thisisforge.com/about/
重定向301/客户端http://rpcdev.thisisforge.com/work/
重定向301/clients/event.htmlhttp://rpcdev.thisisforge.com/work/event-retail-design/
重定向301/clients/identity.htmlhttp://rpcdev.thisisforge.com/work/identity-branding/
重定向301/clients/web.htmlhttp://rpcdev.thisisforge.com/work/web-design/
重定向301/clients/corp_lit.htmlhttp://rpcdev.thisisforge.com/work/brochures-publications/
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
前三个工作正常,但来自特定.html页面的工作正常。我尝试将代码放在WOrdPress代码的上面和下面,并尝试切换我的301s的顺序,以便.html重定向是第一个,而不是最后一个。但这没有帮助。奇怪的是,有时corp_lit.html重定向可以正常工作,但其他重定向则不行。我看不出这有什么道理

我的浏览器或操作系统(windows s7)是否缓存了.htaccess或其他文件中的301s,而这些301s可能是从键入错误时恢复的?我尝试过清空浏览器缓存并在命令提示符下刷新DNS,但没有效果


非常感谢您的帮助。

重定向指令将路径节点链接在一起,因此将应用您的第一个/客户端重定向,而不是下面的重定向,请尝试将其更改为使用RedirectMatch

 RedirectMatch 301 ^/clients/?$ http://rpcdev.thisisforge.com/work/

非常感谢。现在一切似乎都正常了(Firefox确实缓存301重定向,所以我也正因为这个原因努力进行任何更改)。最后一个问题:在修改后的代码中,尾随斜杠是否重要?我希望“/clients”和“/clients/”都能重定向到“/work/”。这似乎对我有用,但我只是想确定这是正式正确的。啊,我在别处找到了我最后一个问题的答案()-似乎是?允许使用或不使用最后一个字符,再次感谢。