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.

use .htaccess to hide Site template group?

May 09, 2010 5:47pm

Subscribe [3]
  • #1 / May 09, 2010 5:47pm

    marcamos

    57 posts

    Hello all,

    I’m currently using .htaccess to hide the index.php file with success and I’ve been wondering about taking it a step further by also hiding the Site template group. For example, I’d love to be able to have a URL such as website.com/rss instead of website.com/site/rss

    My apologies if this has been written-up elsewhere, the Googles had nothing for me.

  • #2 / May 09, 2010 7:24pm

    Wouter Vervloet

    758 posts

    Just edit the .htaccess and slap on /site after index.php

    Greetz,
    Wouter

  • #3 / May 09, 2010 7:31pm

    marcamos

    57 posts

    Thanks for the quick reply; would you mind explaining where in the code it’s meant to be? I’m not so hot with these particular things… Here’s what I’ve got right now:

    # BEGIN Expression Engine Rewrite
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteRule ^(.*)$ /index.php?$1 [L]
    </IfModule>
    # END Expression Engine Rewrite
  • #4 / May 09, 2010 7:49pm

    Wouter Vervloet

    758 posts

    With an example it’s much easier to explain 😊

    # BEGIN Expression Engine Rewrite
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteRule ^(.*)$ /index.php?/site/$1 [L]
    </IfModule>
    # END Expression Engine Rewrite

    That should do the trick…

  • #5 / May 09, 2010 8:29pm

    marcamos

    57 posts

    Ah! Simple as that, huh? I’ll give it a try and report back… many thanks!

  • #6 / May 09, 2010 8:39pm

    marcamos

    57 posts

    Hrmm, that didn’t do the trick. It broke the path(s) to my external resources (css, js, etc.) which are currently coded in the templates like so:

    <link rel="alternate" type="application/rss+xml" title="RSS" href="/site/rss" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/ico" />
    <link rel="stylesheet" type="text/css" href="/styles/reset" media="screen" />
    <link rel="stylesheet" type="text/css" href="/styles/screen-main" media="screen" />
    <link rel="stylesheet" type="text/css" href="/styles/print" media="print" />

    ...and it broke the paths in my navigation, which are currently coded in the templates like so:

    
          <a href="/">Home</a>
          <a href="/about">About</a>
          <a href="/portfolio">Portfolio</a>
          <a href="/blog">Blog</a>
          <a href="/contact">Contact</a>
          <a href="/client-tools">Client Tools</a>
    

    ...not a huge deal really; just interested in tightening up some of my URLs by reducing that one directory up in the address bar. I appreciate the assistance!

  • #7 / May 10, 2010 2:18am

    Wouter Vervloet

    758 posts

    Well… you could always create template groups called about, portfolio, blog, etc… and forget about the whole site group.

  • #8 / May 10, 2010 8:06am

    marcamos

    57 posts

    Actually, that’s what I’ve got now. The thought that lead me down this road, and posed this question, was…

    Currently my template groups and templates look like this:

    - About (group)
    —- Index (template)
    - Blog (group)
    —- Index (template)
    —- Entry (template)
    —- Preview (template)
    - Portfolio (group)
    —- Index (template)
    —- Project (template)
    —- Preview (template)
    - Site (group)
    —- Index (template)
    —- RSS (template)
    —- 404 (template)

    ...and so on. I’ve always thought it was a bit weird to have a URL like this (when viewing a blog entry): website.com/blog/entry/title-right-here/ when it would be cleaner if it were website.com/blog/title-right-here/. I know I could achieve the latter if the template-group/template structure was instead like this:

    - Site (group)
    —- Index (template)
    —- Blog (template)
    —- Portfolio (template)

    ...and so on. See what I mean? If I had all of my site’s templates in one group, and used some basic if/else tags to check for segment lengths, I could effectively get rid of the extra segment in the URL. But, for all templates except the Index template, I’d not want to see /site/ in the URL.

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

ExpressionEngine News!

#eecms, #events, #releases