[Solved] .htaccess mod_rewrite

  • # February 24, 2010 at 2:09 pm

    CLICK TO VIEW RESOLUTION POST: http://css-tricks.com/forums/viewtopic.php?f=6&t=6635

    How would I go about doing this:

    I want all urls that are:


    to be redirected to that same file name but with an expanded directory path


    I am imagining/learning that this is possible, but must be done via a 301 permanent redirection. I just can’t seem to cut through the formatting for .htaccess files to accomplish this. My CMS is taking all my relative links and turning them into root relative… so taking: "../directory/file-name.html" and turning it into "/directory/file-name.html"

    So a link that leads to:


    via relative links for example, is being turned into:


    And breaking.

    Any help would be greatly appreciated.

    CLICK TO VIEW RESOLUTION POST: http://css-tricks.com/forums/viewtopic.php?f=6&t=6635

    # February 24, 2010 at 11:19 pm

    dratts… this doesn’t seem to work. Here is what I have:

    RewriteEngine on
    RewriteBase /about/
    RedirectMatch 301 (.*).shtml http://trinityportland.org/our-school/about/$1

    Things I changed:

      the /directory/
      the domain/subdirectory/
      the .html to .shtml[/list:u]
      Perhaps (apologies, but hopefully) I was just errant in how I described my goal and current situation:

    is the structure of my site.

    The CMS (*sigh*), when encountering relative links (../about/index.shtml) is rewriting that markup as (/about/index.shtml), because it doesn’t work with subsites/sub directories and relative links. You either send it to the root with relative pathing, or you use absolute… As a stop gap, I am using absolute.

    Had I stuck with relative it would send users from their intended destination, for example:


    /assets/various media specific directories/file-name.ext
    and have them redirect to the user requested file-name.ext but at the appropriate sub-directory:


    /assets/various media specific directories/file-name.ext

    This is sounding like a tall order, so even looking this concept over let alone actually providing a snippet sample that I can dupe for all the required directories would be amazing.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed