November 25, 201510 yr I was looking for a particular page on a site (http://url.com/category/page). Notice the page suffix has been removed. Not finding what I was looking for I decided to backspace the url to the category level. Low and behold the site tree appears showing all files in that directory). My question is this: 1 - How and why does this happen? and 2 - How can I make sure this does not happen to me? Please advise for sites built with both a cms (like wordpress) and straight html in a single directory on the host. Thank you.
November 26, 201510 yr That really depends on the CMS and system it uses for creating URL's. For straight HTML you'd create a folder called "category", and inside that place your documents, eg your site structure may be something like, the key is to always have an index.html file in each folder to prevent "directory browsing"; index.html (home page) /category (folder) -- index.html -- page.html - anotherpage.html As for stopping various CMS's doing it you probably need to query the URL to see if there's any content to show for the available URL segments, otherwise redirect to another page. For instance if someone goes to example.com/category and there was no content to show trigger a 404 redirect (page not found). Each CMS has it's own methods for doing this, eg in ExpressionEngine you'd add a simple tag in the category index template to redirect /category to a 404 page. {if segment_2 == ""}{redirect="404"}{/if} You'd need to check the docs for whatever CMS you're using to see what methods are available for that system. Edited November 26, 201510 yr by BlueDreamer
Create an account or sign in to comment