重定向问题,永久链接wordpress

时间:2016-09-29 13:20:23

标签: php wordpress .htaccess url redirect

我有一个wordpress网站,网址是www.mysite.com/name-of-the-post

但客户更改为www.mysite.com/blog/name-of-the-post

现在,点击旧链接的用户遇到问题,他们无法访问内容。

我该如何解决这个问题?我在htaccess上阅读有关正则表达式的内容,我该如何添加" / blog"当用户试图访问旧链接时?

谢谢你们

1 个答案:

答案 0 :(得分:0)

我会把这段代码放在哪里?我的htaccess是这样的:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]

# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# 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