Change search page URL

The following snippet lets you change the search page URL, changing the pesky /?s= URL into /search/.

add_action('template_redirect', function () {
	if (is_search() && isset($_GET['s'])) {
		$current_url = wp_parse_str(wp_parse_url(blocksy_current_url())['query'], $query_args);

		unset($query_args['s']);

		wp_redirect(add_query_arg(
			$query_args,
			home_url("/search/") . urlencode(get_query_var('s'))
		));

		exit();
	}
});

add_action('init', function () {
	add_rewrite_rule(
		'^search\/([^/]*)\/?',
		'index.php?s=$matches[1]',
		'top'
	);
}, 10, 0);
Not the solution you are looking for?

Please check other articles or open a support ticket.