Cubecart v5 rewrite.script for Zeus

Published: August 22, 2012

An Apache rewrite file is provided for those who run Cubecart 5 on the Apache webserver. But what about those who use a web hosting company with Zeus instead of Apache. Well here’s the script I currently use for my clients. It’s working well for us but I can’t provide any guarantees that it will work for you, so please test first.

To install it simply add the text below into a file and save it as rewrite.script, or download it. Then upload it to the root of your Cubecart 5 site.

RULE_0_START:  
    # set original URL  
    set SCRATCH:ORIGINAL_URL = %{URL}  
    set SCRATCH:REQUEST_URI = %{URL}  
    # Set Root Relative Path  
    set SCRATCH:ROOT_REL = /  
    # don't rewrite certain files  
    match URL into $ with ^/.*\.(gif|jpg|png|css|js).*$  
    if matched then  
        goto END  
    endif  
    # check for query string and set accordingly  
    match URL into $ with ^(.*)\?(.*)$  
    if matched then  
        set SCRATCH:QUERY_STRING = $2  
        set SCRATCH:REQUEST_URI = $1  
    endif  
RULE_0_END:  

RULE_1_START:  
    # prepare to search for file, rewrite if its not found  
    set SCRATCH:REQUEST_FILENAME = %{SCRATCH:DOCROOT}  
    set SCRATCH:REQUEST_FILENAME . %{SCRATCH:REQUEST_URI}  
    # check to see if the file requested is an actual file or  
    # a directory with possibly an index. don't rewrite if so  
    look for file at %{SCRATCH:REQUEST_FILENAME}  
    if not exists then  
        look for dir at %{SCRATCH:REQUEST_FILENAME}  
        if not exists then  
            #remove remove forward slash  
            match SCRATCH:REQUEST_URI into $ with ^/(.*)$  
            if matched then  
                set SCRATCH:REQUEST_URI = $1  
            endif  
            #remove .html from the end if it's there.  
            match SCRATCH:REQUEST_URI into $ with ^(.*)\.html$  
            if matched then  
                set SCRATCH:REQUEST_URI = $1  
            endif  
            #set BODY = /index.php?seo_path=%{SCRATCH:REQUEST_URI}  
            #goto END  
            set SCRATCH:REQUEST_URI = /index.php?seo_path=%{SCRATCH:REQUEST_URI}  
            goto QSA_RULE_START  
            #goto END  
        endif  
    endif  
    # if we made it here then its a file or dir and no rewrite  
    #set BODY = %{SCRATCH:REQUEST_FILENAME}  
    goto END  
RULE_1_END:  

QSA_RULE_START:  
    # append the query string if there was one originally  
    # the same as [QSA,L] for apache  
    match SCRATCH:ORIGINAL_URL into % with \?(.*)$  
    if matched then  
        #set BODY = %{SCRATCH:REQUEST_URI}&%{SCRATCH:QUERY_STRING}  
        set URL = %{SCRATCH:REQUEST_URI}&%{SCRATCH:QUERY_STRING}  
    else  
        #set BODY = %{SCRATCH:REQUEST_URI}  
        set URL = %{SCRATCH:REQUEST_URI}  
    endif  
    goto END  
QSA_RULE_END:

Comments:

Works great - saves me hassling the client to move away from Namesco!

Posted by Roland on 26 Aug 2012