In my htaccess, I have rewrite rule for my search page to create clean URL;
Original URL :
http://www.example.com/index.php?keyword=apple
RewriteRule :
RewriteRule ^keyword/([A-Za-z0-9-]+)/?$ index.php?keyword=$1
Clean URL :
http://www.example.com/keyword/apple
That works perfectly unless I type foreign characters. For example, If I write
http://www.example.com/keyword/değişmek
I get 404. That makes sense because the letter ğ and ş are foreign letters. They have to be encoded. But if I write that keyword in original URL,
http://www.example.com/index.php?keyword=değişmek
It works. I get results. Also, I tried to encode what users type in input search for clean URL
var url = encodeURIComponent($("#search-input").val());
window.location.href = "http://www.example.com/keyword/"+ url ;
console.log(url);
didn't work. I get 404. I checked the console.log and the user input is encoded. Therefore, I think rewriterule causes encoding problem. So I have tried to add some flags related to encoding.
RewriteRule ^keyword/([A-Za-z0-9-]+)/?$ index.php?keyword=$1 [NE]
RewriteRule ^keyword/([A-Za-z0-9-]+)/?$ index.php?keyword=$1 [B]
RewriteRule ^keyword/([A-Za-z0-9-]+)/?$ index.php?keyword=$1 [NE,B]
didn't work. Any recommendation?