Rewrite Script for Zeus Web Server
I know that a lot of people that use the Zeus web server are forced into it by their hosting companies (I personally use and love it on its own merits but that's out of place here). Drupal also has some really great styles that make clean URLs very nice and very short. But without support for mod_rewrite in Zeus, you can't use them, until now. I've converted the newest (4.6-newest) rewrite rules into a Zeus rewrite script. I've actually had this for quite a while and never got around to posting it. This faithfully translates:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]into
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:There are a few things to note. Zeus does not support [QSA] or REQUEST_FILENAME or allow reading of server environment variables (you can write to them though..). So much of the script is involved in breaking it down into the QUERY_STRING and REQUEST_FILENAME and then mapping that into the local filesystem path. After that, its really pretty easy. This also assumes your Drupal installation is in your documentroot (ie, / on your website). You can change line 24 (the /index.php? line) to include the directory your Drupal is in, if necessary. Anyway this has worked fine for me for many months, but I'd be curious to know if anyone out there has problems with it.

not sure how to implement?
This is great - I need clean urls to get the gmap module working.
But I am not clear on where I put the Zeus script?
Do I replace the RewriteCond in .htaccess with the Zeus rewrite script?
Thanks.
All Bow Down!
Wow! I was dreading having to do this furthur down my site migration.
BTW, what host are you on? I run zeus because my employer refuses to run apache outside of the firewall.
Do you have any other rewrite scripts you'd like to share?
Same Problem
Where i need to past this script to get clean urls on zeus
regards
Naren
In the zeus admin
Paste into the url rewriting section of the admin.
Thanks Makea
you mean in .htaccess file???
Maybe
Do you have access to the zeus admin pages?
I don't know how it works fif you ar e on a web hosst.
The admin pages are used to completely manage all aspect of the zeus web serverr.
Adding the rewrite rules to a .htaccess may not work (i've never tried), as zeus is supposed to inconvert the apache syntax into zeus's own scripting language.
Zeus does include a feature that converts mod rewrite into zeus' own rewrite language, but iitt doesn't woork well with complex rewrites.
(sorry about the horribly typed post, my macbook pro is dexhisbiting a n odd display artifact issue)
Request to cgi-bin doesn't work
My cgi-bin breaks. I'm assuming it's because the script is only looking at the 'physical' filesystem and not where the cgi-bin is really mapped. Any solutions?
Doesn't work for me :(
Sadly this doesn't work for me, romracer.
I've got no control over the Zeus server itself - just the ability to write .htaccess files.
With either the default Drupal (4.7...) .htaccess file, or with your stuff included, the clean URL test just takes me to the home page. In fact, any URL at all takes me to the home page.
I've checked the Zeus website and can't find any help there, and I've talked to my web hosts but they seem a bit clueless too.
Has anybody got clean URLs working on a Zeus server with only an .htaccess file?
Sadly, this wont work using
Sadly, this wont work using .htaccess files.
You need access to the request rewriting feature in the zeus admin interface.
Zeus isn't apache. It just supports a few popular features like .htaccess to help users migrate away from apache. A lot of the apache-like features aren't fully implemented.
rewite.script
For my host (http://www.names.co.uk/ ) putting the script above in a file called rewrite.script seemed to work.
Actually it needed a bit of
Actually it needed a bit of hacking to work with names.co.uk as the webmail and controlpanel broke
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
# check it's not webmail or controlpanel or tech_support
match SCRATCH:ORIG_URL into % with ^/webmail|^/tech_support|^/controlpanel
if matched then
goto END
else
set URL = /index.php?q=%{SCRATCH:REQUEST_URI}
goto QSA_RULE_START
endif
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:
Thanks to http://www.diturner.co.uk/ for that last bit of the puzzle!
Saving it as rewrite.script
Saving it as rewrite.script worked for me too!
Thanks :D
I've added a page for this to the docs: http://drupal.org/node/577714
I've been unconsciously
I've been unconsciously forced into a "zeus" server and I'm having trouble getting the above to work. At the moment I'm using 6.9 and running out of a /drupal directory. I can't get clean URL's to work and I'm wondering if that is why? I have changed line 24 (to /drupal/index.php)with no luck.
Any Zeus experts still around to give me a hand?
Thanks
The script above worked on names.co.uk you have made me so happy.
Anyone get clean urls working on Zeus?
My client's hosting company (primus) has added the above code, but I still cannot implement clean urls.
Has anyone gotten this to work? Are there any additional steps involved?
Thanks
solved!
If anyone else has a problem with rewrite on Zeus, be sure that the hosting company's own rewrites are not over-writing yours. It might mean the hosting company changing the rule numbers and rule references within the code! At least that's what it was with Primus.
Same problem, but I don't understand what you mean.
Also on Primus - what's the change you needed to make it work?
Help needed to convert Apache mod_rewrite to Zeus script
Hi,
I wander if anyone could help me to convert Apache mod_rewrite to Zeus script. My website is hosted by names.co.uk and I've been trying to do this myself but can't make it work. The script that I need to convert is below:
=========================================================================
#ErrorDocument 404 http://mydomain.com/index.php?module=seo&pId=102
#Please set RewriteEngine to On in order to enable Lightbox SEO
RewriteEngine On
########## Begin - Rewrite rules to block out some common exploits
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits
#for module
# add Date 29/04/2008
RewriteRule ^[//](index|private_gallery)/new_photos(.*)$ /$1.php?link=module/media/pId/101$2 [NC,L]
RewriteRule ^[//](index|private_gallery)/lightbox(.*)$ /$1.php?link=module/lightbox/pId/100$2 [NC,L]
RewriteRule ^[//](index|private_gallery)/products(.*)$ /$1.php?link=module/product_type/pId/100$2 [NC,L]
RewriteRule ^[//](index|private_gallery)/my_account(.*)$ /$1.php?link=module/customer/pId/100$2 [NC,L]
RewriteRule ^[//](index|private_gallery)/shopping_cart(.*)$ /$1.php?link=module/basket/pId/100$2 [NC,L]
RewriteRule ^[//](index|private_gallery)/order_info(.*)$ /$1.php?link=module/company/pId/100$2 [NC,L]
RewriteRule ^[//](index|private_gallery)/about_us(.*)$ /$1.php?link=module/company/pId/101$2 [NC,L]
RewriteRule ^[//](index|private_gallery)/contact(.*)$ /$1.php?link=module/company/pId/102$2 [NC,L]
RewriteRule ^[//](index|private_gallery|logout)/send_lightbox/(.*)?$ /$1.php?link=module/lightbox/pId/104/refer_session/$2 [NC,L]
RewriteRule ^[//](index|private_gallery|logout)/(.*)?$ /$1.php?link=$2 [NC,L]
#end
RewriteRule ^(index|private_gallery)/new_photos(.*)$ $1.php?link=module/media/pId/101$2 [NC,L]
RewriteRule ^(index|private_gallery)/lightbox(.*)$ $1.php?link=module/lightbox/pId/100$2 [NC,L]
RewriteRule ^(index|private_gallery)/products(.*)$ $1.php?link=module/product_type/pId/100$2 [NC,L]
RewriteRule ^(index|private_gallery)/my_account(.*)$ $1.php?link=module/customer/pId/100$2 [NC,L]
RewriteRule ^(index|private_gallery)/shopping_cart(.*)$ $1.php?link=module/basket/pId/100$2 [NC,L]
RewriteRule ^(index|private_gallery)/order_info(.*)$ $1.php?link=module/company/pId/100$2 [NC,L]
RewriteRule ^(index|private_gallery)/about_us(.*)$ $1.php?link=module/company/pId/101$2 [NC,L]
RewriteRule ^(index|private_gallery)/contact(.*)$ $1.php?link=module/company/pId/102$2 [NC,L]
RewriteRule ^(cb.html)$ cb.php
#for all other pages
RewriteRule ^(index|private_gallery|logout)/send_lightbox/(.*)?$ $1.php?link=module/lightbox/pId/104/refer_session/$2 [NC,L]
RewriteRule ^(index|private_gallery|logout)/(.*)?$ $1.php?link=$2 [NC,L]
RewriteRule ^([index\/]+)$ index.php [NC,L]
RewriteRule ^([private_gallery\/]+)$ private_gallery.php [NC,L]
===========================================================================
Thank you
Zeus hosted by Netregistry in Australia
I just found a rewrite script on this site http://www.rootuser.co.uk/content/zeus-sef-urls-and-drupal that worked for me at Netregistry. I had previously tried the script above and another one on drupal.org without luck.
One warning, this site http://www.michaelphipps.com/post/170207973/drupal-htacces-to-zeus-rewrite mentions Zeus not working with the global redirect module and thats exactly what I found as well.
Finally for those newbies like me you do the following to rewrite to netregistry
1. Log in to your console
2. Select "administer domain"
3. Select "webhosting"
4. Enable "Request rewrite support" under webserver options
5. Paste code into text block and click "change"
Assuming you are running Drupal 6 go to the clean url admin page and it will check to see if you can now enable clean url's