.htaccess - 如何从子目录重定向到直接 URL?通过 .Htaccess
问题描述
这是我的问题:
我想从以下位置进行 301 重定向:
domain.com/blog/how-to-stuffs/
至:
domain.com/how-to-stuffs/
请分享 .htaccess 代码,以执行此类重定向,谢谢。
解决方案
尝试:
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]
推荐阅读
- jakarta-ee - 可以在没有 DI 容器的情况下使用 Jersey 吗?
- java - 当所有其他精灵都移动时,为什么 Carpaint 不移动?
- javascript - style.marginLeft 在 wordpress 中不起作用
- reactjs - 收到“警告:‘NaN’ 是‘background’ CSS 样式属性的无效值。” 错误
- c++ - 未定义的引用,但 ld 找到共享 lib 并且 lib 有符号
- android - 如何使用材料组件在 XML 中引用`android:colorBackground`
- azure - 获取 Azure 函数上次运行的时间
- java - 如何使用自定义 url 而不是 Maven Central 来获取依赖项
- c# - 如何同步运行异步任务(最佳实践)?
- c# - 浏览器完成不显示所有元素