Welcome Guest, Not a member yet? Register   Sign In
How to use Zeus Rewrite for Zeus Web Server + Codeigniter, instead of Apache Mod Rewrite
#1

[eluser]Unknown[/eluser]
Hi everyone,

I'm new to the forums but i've been using codeigniter for a few months now. It's excellent by the way.

I just wanted to add this how-to post to help other developers using codeigniter with Zeus as their web server.

Zeus web server is an alternative to Apache. I prefer Apache but had to upload to a clients hosting account and they use Zeus. Zeus doesnt use .htaccess files, instead you have to save a file in the root account as rewrite.script

This script will work if you want to rewrite the index.php file:

If found this code on : http://drupal.org/node/46508 but there was one slight change needed to work for codeigniter.

I changed this line of code :

Code:
set URL = /index.php?q=%{SCRATCH:REQUEST_URI}

to this line ( removed the ?q=% )

Code:
set URL = /index.php%{SCRATCH:REQUEST_URI}

It then allowed me to use other 3rd party software such as fckeditor etc.
Hope this helps anyone looking for Codeigniter, Zeus, Rewrite

Cheers Ross

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%{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:
#2

[eluser]JoJo17[/eluser]
Thanks for sharing this - what a life saver!




Theme © iAndrew 2016 - Forum software by © MyBB