ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Disallow dynamic urls

December 03, 2007 4:18am

Subscribe [2]
  • #1 / Dec 03, 2007 4:18am

    Greg Freeman

    25 posts

    Just a quick question about the gallery module. I have a template group called images.

    http://www.domain.com/images/

    I want to redirect 404 if there is any other segments added.

    i.e If you type

    http://www.domain.com/images/blahblahfakeurl/

    It will load up the index. How can you stop this?

  • #2 / Dec 03, 2007 12:52pm

    Kyle Slattery

    109 posts

    Try something like this in your images/index template:

    {if segment_2}{redirect="404"}{/if}
  • #3 / Dec 03, 2007 3:46pm

    Greg Freeman

    25 posts

    Hi,

    That’s the initial solution I tried before posting this topic. It does not work. I believe redirect only works in a weblog entries tag.

    Also in my gallery category page I am trying

    {exp:gallery:entries gallery="{gallery_name}"  orderby="date" sort="asc" columns="4" rows="5" paginate="both"}
    {if no_results}
      {redirect="404"}
    {/if}

    But if you go to

    http://www.domain.com/images/category/C8/P35000/

    It just shows the first page instead of a 404 error

    Thanks

  • #4 / Dec 03, 2007 4:21pm

    Greg Freeman

    25 posts

    In fact it’s the same with all urls.

    http://www.domain.com/images/view/2209/ is a standard url to view an image. But one can type in http://www.domain.com/images/view/2209/blahblahfake/

    Is there some kind of plugin that you can use to examine the url? Can i use regex? I’m not quite sure what I can with php in the templates yet. Are the templates executed before any output is sent? or are they executed “as you go”?

    I could use php to do what i need to do if it is all parsed before hand.

  • #5 / Dec 03, 2007 5:04pm

    Kyle Slattery

    109 posts

    You can set PHP to be parsed before or after, just set it to “input” or “output” in Templates > Template Preferences Manager

  • #6 / Dec 04, 2007 4:33pm

    Greg Freeman

    25 posts

    Is there not a built in solution? I try to avoid hacking stuff in unless it is absolutely not doable.

    Thanks

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases