Skip to content

How to Exclude Folders from a Zeus rewrite.script

We have recently had a problem with a client’s website which is hosted on a Zeus server, the opposite of Apache servers which allow SEO mod-rewrite files in order to make website addresses look more attractive to visitors.

We wanted to use a rewrite file in order to remove elements of links in WordPress, and looked for many hours on the internet to find one. This we did, and it is on the Drupal.org webpages.

However there do not appear to be any solutions out there for anyone wanting to remove certain folders from the rewrite.script. So for example we use Prestashop on one of our sites and this is not compatible with a rewrite.script at all.

The solution below works well. In order to remove a folder from the rewrite.script, simply change the folder name in the list we have included. You only need to change the text in red to make this work for your site. Upload the rewrite.script to your root directory (or on namesco your /web/ directory to make it work. It is written for WordPress and Drupal CMS type sites.

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
# check it’s not webmail or controlpanel or tech_support
match SCRATCH:ORIG_URL into % with ^/webmail|^/tech_support|^/controlpanel|^/yourfoldername
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:

2 thoughts on “How to Exclude Folders from a Zeus rewrite.script”

  1. admin

    I think you will need to upload the rewrite script into the blog subdirectory. See how you get on.

  2. Ben

    How can I use the above script if the wordpress blog is in a subdirectory called blog?

Leave a Reply