apache - 从主页重定向
问题描述
我有一个条件:a) 从 help.example.com 重定向到 example.com/support b) 从其他页面重定向,例如 help.example.com/catalog 到 example.com/catalog
这就是我在 .htaccess 文件中所做的一切。我的代码仅在 example.com/support 上重定向我
RewriteCond %{HTTP_HOST}${REQUEST_URI} ^help\.example\.com/(.+)
RewriteRule ^(.+)$ example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST}${REQUEST_URI} ^help\.example\.com
RewriteRule ^(.*)$ example.com/support/ [R=301,L]
我该如何解决这个问题?
解决方案
请为您的 a - b 条件尝试此规则:
a) 从 help.example.com 重定向到 example.com/support
RewriteCond %{HTTP_HOST} ^help\.example\.com$ [NC]
RewriteRule ^(/?)$ https://example.com/support [R=301,L]
b) 从其他页面重定向,例如 help.example.com/catalog 到 example.com/catalog
RewriteCond %{HTTP_HOST} ^help\.example\.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
推荐阅读
- java - 使用 JAVA 在 Android Studio 中的简单倒计时
- php - 在 Bluehost 共享主机计划中,如何从 PHP 脚本创建数据库?
- reactjs - 打字稿创建上下文默认值
- rust - 是否通过来自多个线程的相同指针访问对象以进行原子操作未定义行为?
- powerbi - DAX 根据查找 tbl 中存在的所有不同月份将过滤表传递给聚合
- list - 映射两个长度不均匀的列表 - 方案
- jestjs - 使用 jest 自动模拟时,用户模块被视为节点模块
- javascript - 在 BeforeMount 或 Mounted-VUE.JS 中使用道具
- docker - 如何仅列出位于特定私有注册表中的图像
- .net-core - 使用 dll 路径时不支持 dotnet test /p 选项