Feature use dashes #642

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
4 participants
Contributor

JoeCianflone commented Nov 2, 2011

Switch between dashes or underscores for your urls. I had submitted a pull request for this a while back, but it had a couple of bugs and some extra code in there that should not have been pushed, so I'm resubmitting.
Couple of things people had questions on it before:

  • If use_dashes is set to true urls with underscores will bring up a 404, so no duplicate content issues.
  • variables are not checked so you can still have something like x.com/controller-name/func/_id101 if necessary
  • folders aren't checked either so name them however you want.
Contributor

timw4mail commented Nov 2, 2011

Personally, I think it would be better if the underscore urls redirected to the dashed url, rather than throwing a 404.

A 301 redirect makes sense, but maybe this should be configurable as some people might prefer the 404.

Commits look much cleaner this time, except for the extra line in the Welcome controller?

Contributor

JoeCianflone commented Nov 2, 2011

@timw4mail I didn't want to have the urls just redirect because that is a duplication of content. Search engines would ding you for having 2 pages with the exact same content and you would probably have issues with analytics too.

@wildlyinaccurate I could make this configurable my thinking for a 404 was, I guess, regarding a new website. If someone just went to the wrong link, you wouldn't redirect them to the right page and if no one knows your using CI they wouldn't think of typing in underscores. But for the purposes of someone updating their site, I could make this configurable.

Didn't notice the Welcome controller until I already submitted it. I'm still pretty new to Git/GitHub, is there any way to remove that page from the pull request?

Contributor

timw4mail commented Nov 2, 2011

@joeclanflone No, a redirect is not content. A 301 or permanent redirect generally helps more than hurts.

Contributor

JoeCianflone commented Nov 2, 2011

@timw4mail, ok. I'll make that a config option. I'll go with 404 or 301 as the options

@JoeCianflone it's been a while since I've had to do this so I could be wrong - make sure your changes are backed up somewhere just in case! Doing a git reset --hard <SHA1-commit-id> should essentially delete the commit. Then you can re-apply your changes (if necessary) and commit only the files relevant to this pull request.

The commit ID in this instance is b0544fa

Contributor

JoeCianflone commented Nov 4, 2011

@wildlyinaccurate that worked....I did have to recopy my changes in and do a -f on the push, but it worked. I've updated the docs and now you can toggle between 404 and 301 redirects with a config variable.

Contributor

JoeCianflone commented Nov 10, 2011

Bump.

Contributor

JoeCianflone commented Nov 19, 2011

Anyone have any more feedback?

Contributor

narfbg commented Nov 1, 2012

This could be achieved with a simple str_replace() when setting the class and method to be executed. The question is - do we want it?

Contributor

timw4mail commented Nov 1, 2012

@narfbg One of the things I've noticed lately is how much of a pain it is to enter in underscores on mobile devices. Dashes are much easier.

@narfbg narfbg added a commit that referenced this pull request Nov 1, 2012

@narfbg narfbg Allow use of dashes in controller/method URI segments
Supersedes PR #642
d1097a1
Contributor

narfbg commented Nov 1, 2012

Done.

narfbg closed this Nov 1, 2012

@nonchip nonchip pushed a commit to nonchip/CodeIgniter that referenced this pull request Jun 29, 2013

@narfbg narfbg Allow use of dashes in controller/method URI segments
Supersedes PR #642
379438f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment