Is there anything that can be done about trailing slashes? I notice Wordpress cleans this up and is very strict. In EE…
mysite.org/templategroup/template/url-tile
and
mysite.org/templategroup/template/url-tile/
both work and I’ve had pages excluded from ranking for duplicate content before.
In the above URIs, ‘url-title’ is in the 3rd segment in both cases. Trailing slash behavior of path variables and such has not changed in 1.6.5. evasion’s suggestion above on dealing with this via .htaccess is the correct way to address this, if it concerns you.
Removing index.php is at its basest form a server trick. I mean, that ExpressionEngine is only executed when index.php is requested by the server; mod_rewrite merely lets you hide this fact from the visitor. ExpressionEngine still sees the URL segments that your .htaccess rules provide, so as long as the rewritten rule follows the above conventions, whether or not you have renamed or removed index.php from your visitor’s URLs does not matter.
But this won’t work with sites that have removed the template group by mod_rewrite, will it?
While that’s not something we support, it too is still just a server trick. mod_rewrite interrupts the process between the browser and Apache and modifies how Apache, and hence EE, sees the request. As long as the rewritten request meets the above criteria, it doesn’t matter what the visitor is seeing in their brower’s address bar.
Does it means that default group (ie: currently “site”) will appear in the URL ?
What about URL like :
<a href="http://example.com/example/">http://example.com/example/</a>
Will they look like :
<a href="http://example.com/example/index/">http://example.com/example/index/</a>
?
It means that requests for anything other than your site’s main index page must include a valid template group. If you’re using a template group named ‘site’, then yes, ‘site’ would appear in your URLs. That said, the pre-installed template group is nothing more than an example of how templates are constructed. We never intended that people would continue to use that template group (or its name) after learning how to build sites with ExpressionEngine. You should always build your template groups based on your site’s desired URL structure; indeed it defines it.
‘index’ however, will not appear in your URLs. It is analogous to an index.html file within a physical directory which is serving a directory index.
It seems a bit complicated for me, why don’t you simply check if page exists then send 404 headers ?
Well that’s precisely what we are doing with Strict URLs. Checking to see if the template group and template being requested actually exist.
Looks good, although I’m not sure if it’ll get in the way of how I sometimes design my templates.
I’ll sometimes tack on segments to a URL to display different content on the same template. Using your example URL (http://example.com/index.php/news/sprts/) I’d maybe only have a news/index template but completely different content might be displayed on that page if the segment ‘sprts’ is attached to the URL. No template called ‘sprts’ would exist though.
With Strict URLs you could not do that. The index template cannot be used for both multiple and single entry pages, because the second segment does not correspond to a valid template.
Derek, can I disable the Strict URLs then and still keep the 404 page feature?
I’ve come across times in the past when I’ve wished EE would display a 404 page and it hasn’t. I guess you have to be careful what you wish for…I’ve gotten so used to the flexibility of EE’s segments and I might have actually been abusing their usefulness all along.
Yes, you can use the 404 Page without enabling Strict URLs. In this case, it will only validate the first segment, the template group. We realize that developers have come to be familiar with and love ExpressionEngine’s intelligence in working very hard to serve proper content no matter what is requested. It gives a tremendous flexibility both in how you design your site and how visitors can interact with it and the software still serving relevant content. The downside is a somewhat loose 404 interpretation, and our community is now full of people in both camps. This new feature satisfies the newer segment of the community but does not leave the older behind. If you prefer, leaving Strict URLs off while enabling a 404 Page will continue to behave as you’ve come to expect.
Is the following true?
wrong: example.com/index.php/my_site/category/bakery (404 because no template named: category)
right: example.com/index.php/my_site/news/category/bakery (OK. template my_site/news)
Correct!
And that’s an interesting question regarding trailing slashes, how strict should we be about them?
It’s a personal preference. I’ve certainly never found it to be a problem, though aesthetically, the trend is towards not having a trailing slash.
Side question: another source of duplicate content is when calling the index page with an URL title, this causes the display of the single entry which duplicates the single entry page… are you planning this out as well?
Correct, with Strict URLs you will not be able to use URL titles in either the first or second URL segments under any circumstances.