CodeIgniter Forums
Urls with special characters like apostrophe and question mark - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Urls with special characters like apostrophe and question mark (/showthread.php?tid=67487)



Urls with special characters like apostrophe and question mark - wolfgang1983 - 02-27-2017

On my url link if the user click on a like some times the person who post question may use apostrophe


Code:
http://project.com/questions/2/What's-you-all-on-the-forum-doing?


And answer link


Code:
http://project.com/questions/2/What's-you-all-on-the-forum-doing?/42/#42

I have tried using urlencode()

PHP Code:
anchor('questions/' $question['question_id'] .'/'str_replace(' ''-'$question['title']), character_limiter($question['title'], 15), array('target' => '_blank')) 

But now the url outputs

PHP Code:
http://project.com/questions/2/What%27s+you+all+on+the+forum+doing%3F 


How can I still make sure when user has apostrophe, question marks in link title that the url will still work and not throw The URI you submitted has disallowed characters.


RE: Urls with special characters like apostrophe and question mark - wolfgang1983 - 02-28-2017

After doing some more reading through the helpers in url helper I think

url_title() is best suited for my problem https://www.codeigniter.com/user_guide/helpers/url_helper.html#url_title

Now question title url


Code:
http://project.com/questions/2/whats-you-all-on-the-forum-doing

And answer url


Code:
http://project.com/questions/2/whats-you-all-on-the-forum-doing/2/#2



Any other suggestions let me know cheers