So I'm building a simple php application using CodeIgniter that is similar to Let Me Google That For You where you write a sentence into a text input box, click submit, and you are taken to a URL that displays the result. I wanted the URL to be human-editable and relatively simple so I've gotten around the CodeIgniter URL routing a bit. So right now my URLs can look something like this:
http://website.com/?q=this+is+a+normal+url
My problem right now is when the sentence contains a special character like a question mark or a backslash. Both of these mess up with my current .htaccess rewrite rules and it happens even when the character is encoded.
http://website.com/?q=this+is+a+normal+url? OR http://website.com/?q=this+is+a+normal+url%3F
What does work is double-encoding, for example if I take the question mark and encode it to %253F (where the ? is encoded to %3F and the % sign is encoded to %25). So this url works properly.
http://website.com/?q=this+is+a+normal+url%253F
Any idea what I can do here? Is there a clever way I could double encode the input? Can I write a .htaccess rewrite rule to get around this? I'm a little at a loss here.
Here are the rewrite rules I'm currently using for everyone.
RewriteEngine on
RewriteCond %{QUERY_STRING} ^q=(.*)$
RewriteRule ^(.*)$ /index.php/app/create/%{QUERY_STRING}? [L]
Note that the way CodeIgniter works is they have a index/application/function/parameter URL setup. I'm feeding the function the full query string right now.