htaccess redirect from specific urls on home page

2019-08-22 07:04发布

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

Is this possible?

I hope to have a solution.

Thanks

1条回答
Animai°情兽
2楼-- · 2019-08-22 07:09

You need to check at the beginning of you search script if the environment variable QUERY_STRING has an empty value.

For instance, in Perl:

if ($ENV{QUERY_STRING} eq '') {
{print "Status: 307 Temporary Redirect\n";
 print "Location: https://example.com/\n\n";
 exit;
}
查看更多
登录 后发表回答