We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

page url segment problem

Development and Programming

brash's avatar
brash
10 posts
12 years ago
brash's avatar brash

Hi everyone

We’ve found a bug that were having difficulty trying to find a fix for. We have discovered you are able to view a page even if the segments are not correct for the page

For example we would expect to view the page

http://www.churchill-security.co.uk/locations/north-west-security/north-west-security-guards

but if we change segment 2 to be south-west-security (which is a valid segment name) it returns the same page but in an obviously incorrect URL structure

http://www.churchill-security.co.uk/locations/south-west-security/north-west-security-guards

Is there a way to have this page return a 404 ?

       
wildrock's avatar
wildrock
262 posts
12 years ago
wildrock's avatar wildrock

Strict URLs

       
brash's avatar
brash
10 posts
12 years ago
brash's avatar brash

Hi wildrock thanks for your reply but were unable to get the Strict URLs to work for this scenario.

The problem seems to be that as long as segment 2 exists, any page title/slug is allowed to render no mater which segment 2 is used in the URL. We have listed the page under specific categories so we would have expected that it would only render if the category segment name is in the URL and 404 if not but this doesn’t seem to be the case.

Are there any if statements that we could use to check the URL path is correct?

Thanks

       
brash's avatar
brash
10 posts
12 years ago
brash's avatar brash

Can anyone else help with this issue?

       
continental's avatar
continental
2 posts
12 years ago
continental's avatar continental

This might be of some help with segment_2 and strict URLs.

The simple fix (for me anyways):

  1. Enable Strict URLs. (This checks to make sure you have a valid template group)

  2. Within the index.html of that group, add

{if segment_2 != ''}   {redirect="404"} {/if}

Now if someone hits a segment_2 that does not exist, they will be redirected back to the index.html of that group. Since segment_2 is not empty, they will now be redirected to your 404.

Reference: http://ellislab.com/expressionengine/user-guide/cp/design/templates/global_template_preferences.html

I hope this helps with your issue.

       
Boyink!'s avatar
Boyink!
5,011 posts
12 years ago
Boyink!'s avatar Boyink!

What is your segment_2? A template name?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.