htaccess是从首页还是其他页面上的特定URL重定向? [英] htaccess redirect from specific urls on home page or on another page?
本文介绍了htaccess是从首页还是其他页面上的特定URL重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我阅读了20多个帖子,但没有找到解决方案,因此我想在家里重定向 https://example.com/search/
页面或另一页面上,但我不想重定向 https://example.com/search/?q=query
I read over 20 posts, and I did not find a solution, so in my case I want to redirect https://example.com/search/
in home page or on another page, but i don't want to redirect https://example.com/search/?q=query
这可能吗?
我希望有一个解决方案。
I hope to have a solution.
谢谢
推荐答案
您需要在开始时进行检查搜索脚本,如果环境变量QUERY_STRING具有空值。
You need to check at the beginning of you search script if the environment variable QUERY_STRING has an empty value.
例如,在Perl中:
if ($ENV{QUERY_STRING} eq '') {
{print "Status: 307 Temporary Redirect\n";
print "Location: https://example.com/\n\n";
exit;
}
这篇关于htaccess是从首页还是其他页面上的特定URL重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文