Alex Poole

Pragmatic PHP, MySQL, Marketing & Technology

Alex Poole header image 2

mod_rewrite on Zeus for pretty URLs in Wordpress (namesco)

January 28th, 2010 by alex

Just been installing a Wordpress blog on a Namesco Zeus server. Zeus servers don’t use mod_rewrite, they use rewrite.scripts instead. The syntax is totally different. The solution is here at Adam Christie’s blog, but I’ll take the liberty of posting it here too in case that’s ever unavailable:

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:

Stick this in a file called rewrite.script in the root. Job done. Set up permalinks in the usual way. Cheers Adam. Saved me a world of pain :)

Tags:   1 Comment

Leave a Comment

1 response so far ↓