[英]Regex to redirect 301 a folder and all posts from that folder in Wordpress
Just moved my website from www.example.com/blog
to www.example.com
. 刚刚将我的网站从
www.example.com/blog
移到了www.example.com
。
I need to add a 301 redirect to my .htaccess
to redirect everything that is called with the www.example.com/blog/...
url, like a www.example.com/blog/category
to www.example.com/category
or www.example.com/blog/post-title
to www.example.com/post-title
. 我需要向我的
.htaccess
添加301重定向,以将使用www.example.com/blog/...
网址调用的所有内容重定向,例如将www.example.com/blog/category
重定向至www.example.com/category
或www.example.com/blog/post-title
到www.example.com/post-title
。
I've redirected the folder but it doesn't seem to work. 我已经重定向了该文件夹,但是它似乎不起作用。 Can you help me?
你能帮助我吗?
This is the code with the 301 of the folder: 这是文件夹301的代码:
RewriteEngine On
RewriteRule ^blog(/.*)?$ /$1 [L,NC,NE,R=301]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-
RewriteRule ^blog(/.*)?$ /$1 [L,NC,NE,R=301]
RewriteRule ^index\.php$ - [L]
RewriteRule . /index.php [L]
Inside your site root .htaccess have this rule at the top: 在您的网站根目录.htaccess中,顶部具有以下规则:
RewriteEngine On
RewriteRule ^blog(/.*)?$ https://%{HTTP_HOST}/$1 [L,NC,NE,R=301]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.