Using CakePHP on Zeus
- Details
- Published on Friday, 20 January 2012 10:01
- Hits: 171
This is post I reignited from 2009. Thought it might still be valuable to some people....
Recently I have been developing a site using CakePHP. Its a great framework, has been a good learning curve too. For a simple brochure site Cake would be overkill, but for a site with database information it would be great. Any way my post is not about Cake or how good/bad it is… I was merely sharing what I had to do to get Cake to work on hosted Zeus server.
Now most people would know that Zeus servers do not read .htaccess files so I had to overcome the rewrite issue.
I initially followed this post, but I required some query string goodness on my search pages. I then found this post for CodeIgniter another PHP framework, which uses similar traits to Cake.
Combining the two rewrite scripts I came up with one that would work for my Cake application using query strings.
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:DOCROOT . /app/webroot/%{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:DOCROOT}
if not exists then
set URL = /app/webroot/index.php?url=%{SCRATCH:REQUEST_URI}
goto QSA_RULE_START
else
set URL = /app/webroot/%{URL}
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:
