Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other [Solved] .htaccess mod_rewrite

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #28134
    copperSmith
    Member

    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:

    domain.org/directory/file-name.html

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

    domain.org/directory/subdirectory/file-name.html

    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:

    domain.org/directory/subdirectory/assets/style.css

    via relative links for example, is being turned into:

    domain.org/directory/assets/style.css

    And breaking.

    Any help would be greatly appreciated.

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

    #71534
    copperSmith
    Member

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

    Code:
    # BEGIN DIRECTORY REDIRECTION
    RewriteEngine on
    RewriteBase /about/
    RedirectMatch 301 (.*).shtml http://trinityportland.org/our-school/about/$1
    # END DIRECTORY REDIRECTION

    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:

    http://www.trinityportland.org/our-school/index.shtml
    http://www.trinityportland.org/our-school/about/index.shtml[/list:u]
    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:

      /about/

    index.shtml
    /assets/various media specific directories/file-name.ext
    /contact/
    /single/
    /academics/
    /admissions/
    /student-life/
    /alumni-parents/[/list:u]
    and have them redirect to the user requested file-name.ext but at the appropriate sub-directory:

      /our-school/about/

    index.shtml
    /assets/various media specific directories/file-name.ext
    /our-school/contact/
    /our-school/single/
    /our-school/academics/
    /our-school/admissions/
    /our-school/student-life/
    /our-school/alumni-parents/[/list:u]

    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)
  • The forum ‘Other’ is closed to new topics and replies.