首页 > 解决方案 > 如何从子目录重定向到直接 URL?通过 .Htaccess

问题描述

这是我的问题:

我想从以下位置进行 301 重定向:

domain.com/blog/how-to-stuffs/

至:

domain.com/how-to-stuffs/

请分享 .htaccess 代码,以执行此类重定向,谢谢。

标签: .htaccesscpanel

解决方案


尝试:

Redirect "/blog/how-to-stuffs/" "/how-to-stuffs/"

或者,仅在上述方法不起作用时才使用它

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^\/blog\/how-to-stuffs\/?$
RewriteRule ^ /how-to-stuffs/ [R=302,L]

推荐阅读