Support Center

Get Started with eRuby

Last Updated: Jun 01, 2015 01:08PM CDT

Set Up Your cgi-bin Folder

You need to add an 'eruby' script to your '~/public_html/cgi-bin' folder. Here's what it should look like:

#!/bin/bash
echo "Content-type: text/html"
echo
echo "<!DOCTYPE HTML>"
​erubis -E Stdout <$DOCUMENT_ROOT$REQUEST_URI
 

Save the above file as '~/public_html/cgi-bin/eruby' and change its permissions to be executable.

Set Up Your .htaccess File

Finally, you'll need to create an .htaccess file in your '~/public_html/' folder and add the following three lines:

​Action eruby-script /cgi-bin/eruby
AddHandler eruby-script .rhtml
DirectoryIndex index.html index.rhtml 


This will cause any *.rhtml files to load the eRuby script that we just set up, and that file will send the 'rhtml' file through the eRuby parser before displaying it to the user.

Set Up a Rewrite Rule

*This is an optional step.

If you don't like having a 'rhtml' hanging off the end of your URLs, you can add this to the .htaccess file as well:


RewriteEngine on
RewriteRule ^(.*)(?<!\.rhtml)$ $1.rhtml [L] 
 

Now you can upload files ending in '.rhtml' that contain Ruby code enclosed in <% %> or <%= %> markers and have the contents run as Ruby:

<html> 
<body>
1 and 2 is 
<% puts 1 + 2 %>
</body> 
</html>


If you are receiving a 404 (not found) error after setting this up you may need cgi privileges enabled on your account. You can open a support ticket and we will be happy to enable this for you.

b2e1da5554fae60a8baf40cecd3cb9f6@asmallorange.desk-mail.com
https://cdn.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete