Error performing form search with Friendly URL

0

I have the following .htaccess that has worked perfectly so far:

<IfModule mod_rewrite.c>

  RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

  RewriteRule ^es/guarapari/empresas/([0-9]+)/([[a-z0-9-]+)/?$ empresas.php?id=$1&nome=$2&cidade=100 [NC]  

  RewriteRule ^es/guarapari/empresa/([0-9]+)/([[a-z0-9-]+)/?$ detalhes.php?txt=$1&nome=$2&cidade=100 [NC]

  RewriteRule ^es/guarapari\/?$ cidade.php?cidade=100 [L]

</IfModule>

However, I have the following form:

<form action="pesquisa.php" method="get" name="pesquisarguia">
        <input type="text" name="consultarguia" placeholder="Localizar empresa" required="required" class="frm-campos">
        <input class="inenviar" type="submit" value="Buscar">
        </form>

Every time I do a search it gives 404 error because I use Friendly URL.

What inclusion should I make in .htaccess to make my search work?

    
asked by anonymous 12.12.2017 / 17:55

1 answer

1

In the same way that you have "RewriteRule" rules for outrass urls, create one (before all) just for search.

RewriteRule ^es/pesquisa\/?$ pesquisa.php [L]

Then remember to update the action to the friendly url.

<form action="es/pesquisa" method="get" name="pesquisarguia">
    
13.12.2017 / 01:17