从主页重定向
Redirect from main page
我有一个条件:
a) 从 help.example.com 重定向到示例。com/support
b) 从其他页面重定向,例如 help.example.com/catalog 到 example.com/catalog
我在 .htaccess 文件中所做的一切。
我的代码仅在示例中重定向我。com/support
RewriteCond %{HTTP_HOST}${REQUEST_URI} ^help\.example\.com/(.+)
RewriteRule ^(.+)$ example.com/ [R=301,L]
RewriteCond %{HTTP_HOST}${REQUEST_URI} ^help\.example\.com
RewriteRule ^(.*)$ example.com/support/ [R=301,L]
我该如何解决这个问题?
根据您显示的 samples/attempts,请尝试在您的 htaccess 文件中遵循 htacces 规则。请将这些规则放在文件顶部,同时确保在测试 URL 之前清除浏览器缓存。
这将捕获 help.example.com
或 www.help.example.com
两种类型的网址。
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^(?:www\.)?help\.example\.com$ [NC]
RewriteRule ^/?$ https://example.com/support [NE,R=301,L]
请为您的 a - b 条件尝试此规则:
a) 从 help.example.com 重定向到示例。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/ [R=301,L]
我有一个条件: a) 从 help.example.com 重定向到示例。com/support b) 从其他页面重定向,例如 help.example.com/catalog 到 example.com/catalog
我在 .htaccess 文件中所做的一切。 我的代码仅在示例中重定向我。com/support
RewriteCond %{HTTP_HOST}${REQUEST_URI} ^help\.example\.com/(.+)
RewriteRule ^(.+)$ example.com/ [R=301,L]
RewriteCond %{HTTP_HOST}${REQUEST_URI} ^help\.example\.com
RewriteRule ^(.*)$ example.com/support/ [R=301,L]
我该如何解决这个问题?
根据您显示的 samples/attempts,请尝试在您的 htaccess 文件中遵循 htacces 规则。请将这些规则放在文件顶部,同时确保在测试 URL 之前清除浏览器缓存。
这将捕获 help.example.com
或 www.help.example.com
两种类型的网址。
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^(?:www\.)?help\.example\.com$ [NC]
RewriteRule ^/?$ https://example.com/support [NE,R=301,L]
请为您的 a - b 条件尝试此规则:
a) 从 help.example.com 重定向到示例。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/ [R=301,L]