Redirecting Website to Rails App on cPanel

From OCS Support Wiki

Jump to: navigation, search

[edit] Introduction

This article will show you how to redirect your website to a Ruby on Rails app running in cPanel.

[edit] Obtain Your Port Number

Before you proceed, you'll need to know your port number. If you created your Rails application in cPanel, you already have a port number - simply click the URL link and grab the 5 digit number in the URL after the colon.

If you're on Webmin, you'll need a port number to run your Rails application on. If you haven't completed this step yet on Webmin, please obtain one first.

[edit] Redirecting the Website

Create (or edit) the .htaccess file in your public_html folder, and put the following code in it. Remember to replace 12040 with your port number, and yourdomain.com with your domain name.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.yourodmain.com$
RewriteRule ^(.*)$ http://127.0.0.1:12040%{REQUEST_URI} [P,QSA,L]