Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

need help with redirect on Zeus server

  • 15-02-2011 6:50pm
    #1
    Registered Users, Registered Users 2 Posts: 459 ✭✭


    this has kinda got me bogged down (as does the standard .htaccess method)

    I have a Joomla site thats been up for about six months only to realise that robots.txt was allowing indexing of /administrator, now Google has indexed

    /administrator/index2.php
    administrator/index.php?aklazy=check

    My current rewrite script looks like this:
    RULE_0_START:
        # get the document root
        map path into SCRATCH:DOCROOT from /
        # initialize our variables
        set SCRATCH:ORIG_URL = %{URL}
        set SCRATCH:REQUEST_URI = %{URL}
    
        # see if theres any queries in our URL
        match URL into $ with ^(.*)\?(.*)$
        if matched then
        set SCRATCH:REQUEST_URI = $1
        set SCRATCH:QUERY_STRING = $2
        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
        set URL = /index.php?q=%{SCRATCH:REQUEST_URI}
        goto QSA_RULE_START
        endif
        endif
    
        # if we made it here then its a file or dir and no rewrite
        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:ORIG_URL into % with \?(.*)$
        if matched then
        set URL = %{URL}&%{SCRATCH:QUERY_STRING}
        endif
        goto END
        QSA_RULE_END:
    

    How do I set up a 301 redirect in the rewrite.script please?


Comments

  • Registered Users, Registered Users 2 Posts: 459 ✭✭CSU


    ok got it sorted.

    To whom it may concern the Zeus docs tell you to rename .htaccess to .htaccess_old which lead me to believe the the server no longer used it, but it does apparently.

    Now, the Joomla forums gave me the code in the OP and my hosting company gave me more, below is a mixture of both features, TBH I have no idea how secure/unsecure this is.

    Simply use the default .htaccess file ( leave the rewrite engine=on commented out, and the mod_rewrite in use too )

    create a .txt file and name it rewrite.script, paste the code:
    RULE_0_START:
        # get the document root
        map path into SCRATCH:DOCROOT from /
        # initialize our variables
        set SCRATCH:ORIG_URL = %{URL}
        set SCRATCH:REQUEST_URI = %{URL}
    
        # see if theres any queries in our URL
        match URL into $ with ^(.*)\?(.*)$
        if matched then
        set SCRATCH:REQUEST_URI = $1
        set SCRATCH:QUERY_STRING = $2
        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
        set URL = /index.php?q=%{SCRATCH:REQUEST_URI}
        goto QSA_RULE_START
        endif
        endif
    
        # if we made it here then its a file or dir and no rewrite
        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:ORIG_URL into % with \?(.*)$
        if matched then
        set URL = %{URL}&%{SCRATCH:QUERY_STRING}
        endif
        goto END
        QSA_RULE_END:
        
    # ***** SECURITY TO PREVENT CASPER ATTACKS ***** 
    match IN:Host into % with ^(.*)  
    match URL into $ with ^/(.*)\?(.*?(proc|self|environ|mosConfig_[a-zA-Z_]{1,21}(=|\%3D)|base64_encode.*\(.*\)|(\<|%3C).*script.*(\>|%3E)|GLOBALS(=|\[|\%[0-9A-Z]{0,2})|_REQUEST(=|\[|\%[0-9A-Z]{0,2})))  
    if matched then  
    set OUT:Location=http://%1/$1  
    set OUT:Content-Type = text/html  
    set RESPONSE=301  
    set BODY=Moved Permanently  
    goto END 
    endif 
    # ***** PREVENT REWRITE.SCRIPT, .HTACCESS, .HTPASSWD AND .HTGROUP FILES BEING READ IN A BROWSER ***** 
    match URL into $ with ^/(rewrite\.script|\.htaccess|\.htpasswd|\.htgroup) 
    if matched then 
    set URL = / 
    goto END 
    endif 
    # ***** CHECK IF THE URL BEING CALLED EXISTS AS A FILE OR DIRECTORY ***** 
    map path into SCRATCH:path from %{URL} 
    look for file at %{SCRATCH:path} 
    if exists then goto END 
    look for dir at %{SCRATCH:path} 
    if exists then goto END 
    # ***** REDIRECT ALL OTHER REQUESTS ***** 
    match URL into $ with ^/index\.php 
    if not matched then 
    match URL into $ with (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ 
    if matched then 
    set URL=/index.php 
    goto END 
    endif
    endif
    
    :cool:


  • Registered Users, Registered Users 2 Posts: 16,414 ✭✭✭✭Trojan


    I generally try to move my clients off said hosting system to somewhere that supports .htaccess straight up, Zeus is such a pain.


  • Registered Users, Registered Users 2 Posts: 459 ✭✭CSU


    Trojan wrote: »
    I generally try to move my clients off said hosting system to somewhere that supports .htaccess straight up, Zeus is such a pain.

    I hadn't dealt with Zeus servers before I came on-board with my current client and being a total n00b this drove me around the bend for a full day...I just could.not.understand wtf was happening:P

    It is confusing as the CMS wants htaccess and the server wants a rewrite script, I'll know better in the future.


  • Registered Users, Registered Users 2 Posts: 257 ✭✭Log-on


    Hey i have a site up in joomla on zeus, I am upgrading joomla and such so used jupgrade which created site/jupgrade directoy and thats all grand,

    My problem is as you know zeus doesnt use .htaccess it uses rewirte script.

    I cant get rewrite to work on the site/subdirectoy which i want to polish a bit before i move to the root.

    i got rewites working for SEF on the joomla site about 2 years ago and im doing a long over due upgrade, i just cant get the subdirecty rewrite to work and ive no idea why it wont work. any ideas?

    Here is my rewrite code for the root, any idea what has to be changed for a subdirectoy or is new code needed ?


    RULE_0_START:
    # get the document root
    map path into SCRATCH:DOCROOT from /jupgrade
    # initialize our variables
    set SCRATCH:ORIG_URL = %{URL}
    set SCRATCH:REQUEST_URI = %{URL}

    # see if theres any queries in our URL
    match URL into $ with ^(.*)\?(.*)$
    if matched then
    set SCRATCH:REQUEST_URI = $1
    set SCRATCH:QUERY_STRING = $2
    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
    # check it's not webmail or controlpanel or tech_support
    match SCRATCH:ORIG_URL into % with ^/webmail|^/tech_support|^/controlpanel
    if matched then
    goto END
    else
    set URL = /index.php?q=%{SCRATCH:REQUEST_URI}
    goto QSA_RULE_START
    endif
    endif
    endif

    # if we made it here then its a file or dir and no rewrite
    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:ORIG_URL into % with \?(.*)$
    if matched then
    set URL = %{URL}&%{SCRATCH:QUERY_STRING}
    endif
    goto END
    QSA_RULE_END:


Advertisement