Home / htaccess / Redirect empty searches to root
  • How to Redirect empty searches to root

    redirect-empty-searches-to-root

    Adding this snippet to your .htaccess file, will redirect empty searches to root. Be sure to backup your htaccess first.

    ( click code to copy )

    wordpress snippet : .HTACCESS

    <>
    # Redirect Empty Searches to root
    RewriteCond %{QUERY_STRING} ^s=$
    RewriteRule ^ /? [L,R=301]
    

    ( WordPress codex functions, hooks, in this snippet. )

    query, query_string,