Posted: October 27th, 2008
Zeus Webserver WordPress Permalinks Rewrite
![]()
I have since been looking at the rewrite for WordPress and also to use in my own custom built sites for search engine friendly URL’s. Again I found very little on the web, but currently have a working model. The rewrite script passes the URL into a variable ‘q’. So to get it out again I simply passed ‘q’ into an array with the following PHP:
When I have more time, I intend to have a deeper look at WordPress and how they do things. But for now, here is the rewrite code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 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: |
Share this post:










Handy script for those Zeus users like myself. However, I’m baffled at how I need to adapt the script for use with two installations.
I have two WordPress installations on sultanas-nights.com, one on the root, and one on /tr. I achieved SEO permalinks successfully for the root domain.
However, I need to adapt the script to support all addresses that are under the subdirectory “/tr/” as well as the root. Currently it doesn’t fully work (ie the site isn’t loaded fully with all CSS and only text is displayed), as you’ll be able to log on and see…
Any ideas?
Hi Alp,
Interesting question and I have sent you an email with a draft rewrite file, which is adapted with an IF statement to run two rules based on whether it matches the sub folder. Let me you how you get on and once working, I’ll post it on here.
James