What does "Enable Strict URLs" really mean and are there any security/other implications if I choose to not use strict URLs?
-
2+1. I still have no idea what this actually does, but I always enable it because it sounds like a good thing :)– Adrian MacneilCommented Nov 22, 2012 at 8:51
-
I end up doing the same though it does have one annoying side effect: expressionengine.com/user_guide/cp/design/templates/…– Tom DaviesCommented Nov 22, 2012 at 8:54
4 Answers
My URL schematic points out the difference it makes to the regular flow - might be helpful:
http://www.jamessmith.co.uk/articles/expressionengine_url_schematic
As you can see from the diagram, it prevents EE from determining a template via methods #2 and #4 method #2 as numbered there (and as alluded to in the other answers).
For me the benefit of more reliable 404's doesn't outweigh the advantage of being able to determine a template in these ways this way, so I never enable it.
[answer corrected May 2013 - You CAN have Strict URLs turned on and still use method #4.]
-
2Awesome! totally forgot about that schematic. We should add that to the wiki here. Commented Nov 22, 2012 at 14:21
-
2That schematic is going to be added to my debug toolbox. Thanks James pure gold. Commented Nov 22, 2012 at 18:41
-
2My pleasure. @CreateSean what and where is there a wiki here? Can't see that anywhere? It's a strange old game this Stack Exchange malarkey. Commented Nov 22, 2012 at 23:35
-
1James, there's supposed to be a wiki, but I haven't figured it out yet. might be something that happens when we have users with higher rep. Commented Nov 23, 2012 at 0:54
With Strict URLs off, if your first segment doesn't correspond to an existing template group, EE will then look for a template with the same name in your default template group, and render that template if found.
Enabling Strict URLs prevents the behaviour - if {segment_1}
is not a template group (and your URL is not a Pages URL), you'll get a 404.
My understanding of strict urls is as follows:
Lets say you have a news template/channel.
if you go to site.com/news/ this (assuming you've coded it so) will show you a list of all news items on the page.
You now have a site.com/news/view/url_title_here which is a single list page based on the last segment being the URL_TITLE of the news item.
My understanding with strict URL's is that if you were to go to site.com/news/view/ without strict url's being enabled, it would simply show the 'latest' news item - however with it enabled, it will error/404.
At least thats always been my understanding.
-
-
1There's an additional effect of enabling strict URLs that has caught me out before: with it on, you can view templates in your default template group directly by template name, without specifying the group in the URL, eg:
example.com/template_name
, whereas with it off you cannot, and must access them asexample.com/template_group/template_name
. Commented Nov 22, 2012 at 9:21 -
1Tom - I think you mean that in reverse? Strict URLs on means that you always need to specify the template group. Commented Nov 22, 2012 at 13:25
-
1@madebyhippo - this is actually not true. This behaviour only occurs if you specify
require_entry="yes"
in your Channel Entries tag, and then you add{if no_results}{redirect="404"}{/if}
. Strict URLs has no effect on the scenario you describe. Commented Nov 22, 2012 at 13:30 -
@DerekHogue, you're quite right - will amend my comment Commented Nov 22, 2012 at 18:56
Backing up a little: My understanding is that Strict URL's were implemented because of duplicate content* issues - duplicate content is rarely an issue at all anyway. Google will just decide to index 1 page. It would be possible to run into a canonical issues but again that's rare.
- Different duplicate content than copying other sites and trying to out rank for that content.
Personally i don't run strict urls as it makes url's ugly although- by reading above i need to revisit and test a few things for clarification in my mind how exactly it works.