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.

Comments

dpauld’s picture

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.

Makea’s picture

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?

r_naren22’s picture

Where i need to past this script to get clean urls on zeus

regards
Naren

Makea’s picture

Paste into the url rewriting section of the admin.

r_naren22’s picture

you mean in .htaccess file???

Makea’s picture

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)

Makea’s picture

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?

Mark Nielsen’s picture

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?

Makea’s picture

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.

bloke_zero’s picture

For my host (http://www.names.co.uk/ ) putting the script above in a file called rewrite.script seemed to work.

bloke_zero’s picture

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!

gearoidocathain’s picture

Thanks to everyone that contributed to this! Got some lovely clean urls happening now on my site.

trkest’s picture

Many thanks for this.
Names.co support were not at all helpfull but this solved it.

It will be interesting to see if they can still claim to support Drupal 8 which does not work without clean urls.

joachim’s picture

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

jptaranto’s picture

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?

goldengirl’s picture

The script above worked on names.co.uk you have made me so happy.

myron_s’s picture

I know what you mean and I'm struggling too. I've inherited a site that has been installed in a /counselling subdirectory. I know what's happening, just that I don't know what put in the script to correct it.

If I try use the URI /counselling/staff then the script changed this to /counselling/index.php?q=/counselling/staff and not to /counselling/index.php?q=staff. So this is why for me Clean URLs don't work.

The line in question is:
set URL = /counselling/index.php?q=%{SCRATCH:REQUEST_URI}
Where %{SCRATCH:REQUEST_URI} = /counselling/staff
The puzzle is how to remove /counselling/ from %{SCRATCH:REQUEST_URI}.

Does anyone know how to solve this? If this can be solved then the solution will be universal for any Drupal site installed in a subdirectory.

EDIT:

Found the solution:

Excerpt of code from full re-write script:

# 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
    match SCRATCH:REQUEST_URI into $ with ^/FOLDER-OF-DRUPAL-SITE/(.*)$
	set SCRATCH:NODE_OR_ALIAS = $1
	set URL = /FOLDER-OF-DRUPAL-SITE/index.php?q=%{SCRATCH:NODE_OR_ALIAS}
    goto QSA_RULE_START
  endif
endif

This works. Drupal site is in a sub-directory off the web-root. Clean URLs work. YIPEE!!!

jenpasch’s picture

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

jenpasch’s picture

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.

tbase’s picture

Also on Primus - what's the change you needed to make it work?

just_minde’s picture

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
Visitor82’s picture

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

thtas’s picture

I'm trying to get this working with Netregistry but it's not working.
Unfortunately, I am stuck with having to install drupal to a sub-directory.

I tried changing the line: /index.php?q=% to /subdir/index.php?q=% with no luck

Anybody have any experience with these scripts and drupal in a sub-directory

*EDIT*

I found this script which has support for sub-directories buit in and it works!
http://modxcms.com/forums/index.php/topic,14927

muddie’s picture

I am using Hostess which is the cheap version of Netregistry and your instructions worked perfectly!

bdiddymc’s picture

Hello All,

I have just made some alts to my site. Instead of using underscores to separate words I have changed it to hyphens.

I am not sure on the syntax for Zeus servers. Is there anyway to list pages and supply the new url for 301 redirects

So basically the Zeus version of doing the Apache:
redirect 301 /old_link http://www.mysite.com/new-link
redirect 301 /second_old_link http://www.mysite.com/another-new-link

Have tried a google search, but all examples seem to focus on more general snipets rules throughout the site, rather than specific page changes.

Any help would be appreciated.

mrhassell’s picture

Hi Muddie,

Really would like to know how you got this working with Hostess / Netregistry as I have tried the same with no success, which is strange - does this look familiar?

Testing clean URLs...

Your system configuration does not currently support this feature. The handbook page on Clean URLs has additional troubleshooting information.

Glen

KoshaK’s picture

There is two languages onthe Website Russian and English, With Clean URLs enabled I can't switch to Russian Language ( Page not found ) and overall behavior of the page is strange, If I'm on russina page switching to english page it's switching but then Menu is missing... I have been searching for answers and only solution I have found is " Move to Apachi! ".
Any sugestions?

Mark Nielsen’s picture

If at all possible, I'd avoid working on a Zeus server. The one Drupal site, based on a Zeus server, which I was responsible for has caused me no end of headaches over the last few years, and I've just recently given that project up.

So, if you can, use Apache. And apologies for this slightly negative post, but am just sharing my (subjective) experiences.

Good luck!

KoshaK’s picture

Well thanks for sharing experience, but the best experience the one I have received right now ;o)
I pointed out to Hosting support that I will have to cancel the account if problem will not be sorted.
So - it's up to them - fix it or leave it...

developer@ican.ie’s picture

Hi - i need the translation of the below MULTI SITE Apache htacess code translated into Zeus as my hosting company only runs Zeus? I've searched everywhere on the web but can't find anything? - PLEASEEEEE help?

------------------------------------
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
------------------------------------------------

deselse’s picture

Any body can resolve this ? Im having similar problem scope. Have been googling around but none of them are satisfied.