keji
keji

Reputation: 5990

RewriteRule doesn't like multiple words

Ok I have a problem using $_GET with htaccess. If I search for "post title" i go to http://site.com/search/post%20title and this line:

RewriteRule ^search/([a-zA-Z0-9_-]+) search.php?post_title=$1

Would create that $_GET but it only does so for the first word if I:

echo $_GET['post_title'];

I only get the first word how would I fix this?

Thanks in advance!

Upvotes: 1

Views: 124

Answers (2)

Mike Mackintosh
Mike Mackintosh

Reputation: 14237

RewriteRule ^search/([a-zA-Z0-9_-\s]+) search.php?post_title=$1

This defines a space as \s

Upvotes: 3

Waleed Khan
Waleed Khan

Reputation: 11467

Add a space to your character class:

RewriteRule ^search/([a-zA-Z0-9 _-]+) search.php?post_title=$1

Upvotes: 2

Related Questions