htaccess 从主页或其他页面上的特定 url 重定向?
htaccess redirect from specific urls on home page or on another page?
我阅读了 20 多篇文章,但没有找到解决方案,所以就我而言,我想在主页或其他页面上重定向 https://example.com/search/
,但我不想重定向 https://example.com/search/?q=query
这可能吗?
希望有解决办法。
谢谢
您需要在搜索脚本的开头检查环境变量 QUERY_STRING 是否为空值。
例如,在 Perl 中:
if ($ENV{QUERY_STRING} eq '') {
{print "Status: 307 Temporary Redirect\n";
print "Location: https://example.com/\n\n";
exit;
}
我阅读了 20 多篇文章,但没有找到解决方案,所以就我而言,我想在主页或其他页面上重定向 https://example.com/search/
,但我不想重定向 https://example.com/search/?q=query
这可能吗?
希望有解决办法。
谢谢
您需要在搜索脚本的开头检查环境变量 QUERY_STRING 是否为空值。
例如,在 Perl 中:
if ($ENV{QUERY_STRING} eq '') {
{print "Status: 307 Temporary Redirect\n";
print "Location: https://example.com/\n\n";
exit;
}