John McCollum

Removing index.php for Codeigniter (Zeus Server)

Just a quick post – spent a few hours the other night trying to get Zeus Rewrite to play ball so that this:

http://www.example.com/index.php/controller

turned into this:
http://www.example.com/controller

There’s a distinct lack of examples for Zeus rewrite, but here’s what worked for me:
map path into SCRATCH:DOCROOT from /

set SCRATCH:REQUEST_URI = %{URL}

look for file at %{SCRATCH:DOCROOT}%{SCRATCH:REQUEST_URI}
if not exists then look for dir at %{SCRATCH:REQUEST_URI}%{SCRATCH:REQUEST_URI}
if not exists then set URL = /index.php%{SCRATCH:REQUEST_URI}

Your mileage may vary; some tweaking may be required for your particular set up. Hopefully this post saves someone some work!

Posted in PHP, web development by admin at December 6th, 2008.
Tags: ,

3 Responses to “Removing index.php for Codeigniter (Zeus Server)”

  1. waelNo Gravatar says:

    Thank you for your script it work fine on the site but once you login to the admin panel it doesnt work any more
    here is another script that work 100%

    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:

  2. adminNo Gravatar says:

    Hi, thanks for your solution, wael. The only issue I had was that the customer’s webmail was found at http://www.example.com/webmail – which then threw a not found error. I solved this by creating a subdomain pointing to webmail – this did the trick for me.

    Thanks for your solution!

  3. OakNo Gravatar says:

    Thanks for this script, I have had endless problems with Zeus Rewrite in the past.

Leave a Reply

This site is using OpenAvatar based on