【发布时间】:2018-10-17 09:44:15
【问题描述】:
我一直在努力将旧网址重定向到新网站页面。
目标是重定向许多子文件夹页面,例如: https://www.example.com/news/events/event18
到一个唯一的文件夹:https://www.example.com/focus
在 Wordpress 中使用 htaccess 文件,我试过了:
RedirectMatch 301 /oldfolder1/oldpage1/(.*) /newfolder/$1
结果是:
https://www.example.com/newfolder/oldpage1
另一种方法:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^oldfolder/(.*)$ https://www.example.com/newfolder [R=301,L]
结果是一样的!
我有很多旧网址,我想避免手动 Redirect 301 为所有这些网址。
谢谢帮助。
【问题讨论】:
标签: wordpress .htaccess redirect http-status-code-404 http-status-code-301