【发布时间】:2016-01-12 09:44:29
【问题描述】:
我最近创建了一个与 Serverpilot 一起使用的新 droplet。因此,我创建了一个新的 droplet,并使用 All in one WP 迁移插件从我的旧 droplet 迁移了内容。在永久链接设置中,我维护了以前的永久链接结构,即 example.com/post-name 并保存了设置。
但是,突然之间,我可以看到 example.com/blog/dd-mm-yy/post-name 的自然流量(搜索引擎流量),这显然是返回未找到的 404 页面。
我不知道这是否是临时问题,因为我已经设置了正确的永久链接结构。
现在我想将任何访问 example.com/blog/date/post-name 的流量重定向到 example.com/post 名称。对于所有的帖子。基本上,我想从所有帖子中删除 /blog/dd-mm-yy,以便可以将用户重定向到 example.com/post-name。
有什么方法可以从 .htaccess 中做到这一点?
.htaccess 文件如下所示:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ %{HTTP_HOST}/$1 [R=301,L] RewriteRule ^blog/(?:\d+/)+/([^/]+/?)$ /blog/$1 [L,NC,R=301]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
【问题讨论】:
标签: wordpress .htaccess redirect