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.

Template/page URL query

April 04, 2011 8:00am

Subscribe [2]
  • #1 / Apr 04, 2011 8:00am

    andrew_spl

    71 posts

    I need to create a site with the standard template/page URL structure (I can’t use the page module for this site) using just a few generic templates. Does anyone know of a way to effectively remove the name of the basic template from the URL? So instead of

    <a href="http://www.domain.com/products/generic-template/myproducts">http://www.domain.com/products/generic-template/myproducts</a>
    it would appear
    <a href="http://www.domain.com/products/myproducts">http://www.domain.com/products/myproducts</a>

    Thanks,

    Andrew

  • #2 / Apr 06, 2011 4:29am

    Brett Gullan

    70 posts

    Hi Andrew,

    One way to do this would be to use a rewrite rule in your .htaccess file. Do a Google search on something like this “.htaccess rewrite remove a url segment” and you’ll get plenty of info.

    Alternatively, you could direct all requests to your ‘products/index’ template, and use a switch/conditional to embed the appropriate “sub-templates”. This is a little less efficient, but easy enough to do.

    Something like this might work:

    {if segment_2 == 'whatever'}
            {embed="products/whatever-template"}
    {if:elseif segment_2 == 'something'}
            {embed="products/something-template"}
    {if:elseif segment_3 != ''}
            {embed="products/another-template"}
    {/if}

    HTH

  • #3 / Apr 06, 2011 5:14am

    andrew_spl

    71 posts

    OK, that’s interesting, thanks very much for your help.

    Andrew

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

ExpressionEngine News!

#eecms, #events, #releases