Ok I've finally got a Silverstripe website to behave properly on a Namesco Zeus Server ( Register365 here in Ireland ) with teh help of a lot of individual posts on this forum and some playing around, so I thought I should post the final solutions here for anyone that might be stuck trying to get mod_rewrite working on a Zeus server.
Firstly - put this code into a file named rewrite.script in the root of your site:
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 = /sapphire/main.php?url=%{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:
Then, I had a problem where index.php kept getting added to the links on the homepage only - and solved this by opening the index.php file and changing the BASE_SCRIPT_URL from
define('BASE_SCRIPT_URL','index.php/');
to
define('BASE_SCRIPT_URL','');
Hope this helps,
Neil