Welcome Guest, Not a member yet? Register   Sign In
Tutorial, News, Case sensitive
#1

Hi

I am trying to learn CodeIgniter, so I started with the tutorial.

I already managed to complete the static pages and news displaying part.

However, the News section is case sensitive and that bothers me.

When I go localhost/ci/news - it works
however, if I write localhost/ci/News - it shows 404
if I link to a concrete news post with lowercase letters without the view part- news/firstpost - it works
if I link to a concrete news post with different sized letters without the view part- nEws/firstpost - it shows 404

and finally
if I link to a conrete news post -news/view/firstpost - it works
if I link to a concrete news post with different sized letters - nEws/view/firstpost - it also works


As for Pages - they are not case sensitive (meaning About, about or even AbouT works)

Everything I did so far is copy paste code from tutorial.

I am lost and don't know how to make News case insensitive.
Reply
#2

I am not sure what the problem you are solving is, but if I go to http://www.bbc.co.uk/iplayer it works fine and if I go to http://www.bbc.co.uk/iplayeR it does not. This is just how URL's are.

If you need to make a variable sent in the controller/method/variable url format, case insensitive, just us strtolower() on the variable before using it, so everything is made lower case.

Why does case sensitivity bother you?

Best wishes,

Paul.
Reply
#3

If you want URL like nEws/view/firstpost, you have to modify CodeIgniter core class, haven't you?
It is against CodeIgniter conventions.


Quote:As for Pages - they are not case sensitive (meaning About, about or even AbouT works)

You are using case insentive file system (eg, Mac OS X or Windows). If you use case sensitive file system (eg, Linux), it won't work.
Reply
#4

You can make the route for news case-insensitive, but you have to use a RegEx. For example, you could use:
PHP Code:
$route['(?i)(news)'] = 'news'

but you'd have to add additional routes for the supported segments to maintain that case-insensitivity for news/firstpost, news/view/firstpost, etc.

Honestly, with over 100 potential 1st segments for the URLs on my website, I only have one route setup like this, and I didn't bother with setting up the additional segments after I pointed out to the person who complained that they couldn't do this with URLs that they had spelled a word incorrectly in addition to putting capital letters where they didn't belong.

Despite our desire to have easy-to-read URLs (which also happen to be SEO-friendly), most people never input URLs manually, so this rarely matters. In my opinion, though, it's better to be consistent than permissive with URLs.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB