mod_rewrite rules for live site

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dennis.sprengers@gmail.com

    #1

    mod_rewrite rules for live site

    * I'm trying to work out some rewrite rules that should do the
    following:

    case 1: a request to mysite.com:
    rewrite http://www.mysite.com/files/sheets.ppt
    to http://www.mysite.com/sites/default/files/sheets.ppt

    case 1 - n: a request to othersite.com:
    rewrite http://www.othersite.com/files/sheets.ppt
    to http://www.othersite.com/sites/other...les/sheets.ppt

    So, if a request comes in to mysite.com, /files/-urls need to be
    rewritten do /sites/default/files/sheets/ppt, since mysite is the
    default website on the server. Surfing to a file on any other website
    that is hosted on the server, needs to be rewritten to /sites/
    <name_of_site >/files/sheets.ppt

    Sheets.ppt is of course just an example of a file file.

    * I first tested my CMS (for which I need these rules) on my own
    little server @home, and found these rules to be working OK after
    spending hours on forums on apache and mod_rewrite:

    # http://localhost/mysite/files/* /mysite/sites/default/files/*
    RewriteCond %{REQUEST_URI}-default ^/mysite/.+-(default)$ [NC,OR]
    # http://loclahost/<othersite>/files/* /<othersite>/sites/
    <othersite>/files/*
    RewriteCond %{REQUEST_URI}-default ^(.+)(default)$ [NC,OR]

    But now I have no clue on where to begin anymore, since it has been a
    long time I researched mod_rewrite. Could somebody help me out? Any
    help is appreciated :-)

  • ZeldorBlat

    #2
    Re: mod_rewrite rules for live site

    On Oct 27, 1:22 pm, dennis.spreng.. .@gmail.com wrote:
    * I'm trying to work out some rewrite rules that should do the
    following:
    >
    case 1: a request to mysite.com:
    rewritehttp://www.mysite.com/files/sheets.ppt
    tohttp://www.mysite.com/sites/default/files/sheets.ppt
    >
    case 1 - n: a request to othersite.com:
    rewritehttp://www.othersite.c om/files/sheets.ppt
    tohttp://www.othersite.c om/sites/othersite/files/sheets.ppt
    >
    So, if a request comes in to mysite.com, /files/-urls need to be
    rewritten do /sites/default/files/sheets/ppt, since mysite is the
    default website on the server. Surfing to a file on any other website
    that is hosted on the server, needs to be rewritten to /sites/
    <name_of_site >/files/sheets.ppt
    >
    Sheets.ppt is of course just an example of a file file.
    >
    * I first tested my CMS (for which I need these rules) on my own
    little server @home, and found these rules to be working OK after
    spending hours on forums on apache and mod_rewrite:
    >
    #http://localhost/mysite/files/*/mysite/sites/default/files/*
    RewriteCond %{REQUEST_URI}-default ^/mysite/.+-(default)$ [NC,OR]
    #http://loclahost/<othersite>/files/* /<othersite>/sites/
    <othersite>/files/*
    RewriteCond %{REQUEST_URI}-default ^(.+)(default)$ [NC,OR]
    >
    But now I have no clue on where to begin anymore, since it has been a
    long time I researched mod_rewrite. Could somebody help me out? Any
    help is appreciated :-)
    You're making it harder than you need to. Just use an alias:

    Alias /files <path to the webroot>/sites/default/files

    Comment

    • dennis.sprengers@gmail.com

      #3
      Re: mod_rewrite rules for live site

      You're making it harder than you need to. Just use an alias:
      >
      Alias /files <path to the webroot>/sites/default/files
      I would really like it to work with mod_rewrite rules in .htaccess, so
      that I don't have to create a new alias for every website I might add
      in the future. So if you understand mod_rewrite, please throw me a
      bone here :-)

      Comment

      • Jerry Stuckle

        #4
        Re: mod_rewrite rules for live site

        dennis.sprenger s@gmail.com wrote:
        * I'm trying to work out some rewrite rules that should do the
        following:
        >
        case 1: a request to mysite.com:
        rewrite http://www.mysite.com/files/sheets.ppt
        to http://www.mysite.com/sites/default/files/sheets.ppt
        >
        case 1 - n: a request to othersite.com:
        rewrite http://www.othersite.com/files/sheets.ppt
        to http://www.othersite.com/sites/other...les/sheets.ppt
        >
        So, if a request comes in to mysite.com, /files/-urls need to be
        rewritten do /sites/default/files/sheets/ppt, since mysite is the
        default website on the server. Surfing to a file on any other website
        that is hosted on the server, needs to be rewritten to /sites/
        <name_of_site >/files/sheets.ppt
        >
        Sheets.ppt is of course just an example of a file file.
        >
        * I first tested my CMS (for which I need these rules) on my own
        little server @home, and found these rules to be working OK after
        spending hours on forums on apache and mod_rewrite:
        >
        # http://localhost/mysite/files/* /mysite/sites/default/files/*
        RewriteCond %{REQUEST_URI}-default ^/mysite/.+-(default)$ [NC,OR]
        # http://loclahost/<othersite>/files/* /<othersite>/sites/
        <othersite>/files/*
        RewriteCond %{REQUEST_URI}-default ^(.+)(default)$ [NC,OR]
        >
        But now I have no clue on where to begin anymore, since it has been a
        long time I researched mod_rewrite. Could somebody help me out? Any
        help is appreciated :-)
        >
        >
        And your PHP question is?

        Try an appropriate newsgroup - such as alt.apache.conf iguration.


        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        Working...