A rewrite.script file to replace .htaccess files for Expression Engine users on Register365
3 min readNamesco a.k.a. Register365 are soon to begin the process of moving their users from a ‘legacy’ H-Sphere system to a new hosting platform. Annoyingly, they don’t really mention that the new platform runs on Zeus server software rather than Apache. This is set to cause headaches for a lot of users as urls which are rewritten using the mod_rewrite module will no longer work.
Although users will be automatically moved at some point in the future, you can choose to manually move your data and reconfigure any settings now should you so wish.
Which is what we did for one of our clients over the weekend. Only to find that the “Linux Web Hosting” package is on a Zeus server. Whoever heard of the LZMP stack?
Anyhow, the first casualty was our SEO and human friendly URLs. So if you’re using Expression Engine on a Names.co.uk or Register365.ie Zeus server, and you’ve been dropping the index.php from URLs by using mod_rewrite in a .htaccess file, then this is for you:
Create a rewrite.script file – this goes into the same directory as your old .htaccess file.
Copy the following code into the file:
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%{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:
Please note, this code is almost entirely based on work found in this post: http://drupal.org/node/46508 which was customised for Names.co.uk so as not to break the /controlpanel and /webmail urls. We just added a tiny bit of extra customisation to get it working properly for Expression Engine.
You should also note that for the most part a .htaccess file will still run smoothly on Zeus.
Finally, I’ve had it confirmed by support at Namesco / Register365 that CRON jobs are not supported on Zeus servers – although they might help you out if you plead your case.