How to fix url after submit search

Hello,

I dont know how to fix this problem i am stuck here for 2 days.

Here below i change the URL to make it seo friendly and it works.

From:

example.com/search.php?search=funny

To:

example.com/ search/funny

with:

RewriteRule ^search/([^/]*)$ /search.php?search=$1&submit=Submit [L]

But when i search again i get this:

example.com/ search/funny + this > ?search=car
example/com/search/funny?search=car < +

And it should be

example.com/search/car

Thanks in advance.

Umm…Try this? I think?

RewriteRule ^search/.+/([\d]+)(\/)?$ /search.php?search=$1

Thanks for the fast reply.

I have the same problem, and i get a blank page.

I found the solution at:
http://stackoverflow.com/questions/5464481/clean-urls-for-search-query

With this form.

<form method="get" action="/search/" onsubmit="return false;">
<input type="search" name="q" value="querystring" />
<input type="submit" onclick="window.location.href=this.form.action + this.form.q.value;" />
</form>

and i added this rule at my .htaccess file:

RewriteRule ^search/([^/]*)$ /search.php?search=$1&submit=Submit [L]

Clean url works if i search a single word like Funny:

I get this url which is good.

http://www.example.com/search/funny

But if i search Funny Videos i get:

http://www.example.com/search/funny%20videos

How to solve the problem ? And remove %20 from the url.

Thanks in advance.

Tasos,

%20 if the encoded reference for a space. That CAN be handled by mod_rewrite if you escape (backslash) the space WITHIN a character range definition, i.e., ([a-zA-Z\ ]+).

Regards,

DK

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.