I'm trying to set up a Rails website on Bluehost and I'm having trouble with the path helpers. As I don't want to monkey-patch Rails, I'm trying to solve this through .htaccess. Here's the scenario:
- I'm hosting
www.engradado.com
onpublic_html/engradado
, which points torails_apps/engradado/public
I'm rewriting
www.engradado.com
to point towww.engradado.com/engradado
, through thispublic_html/.htaccess
file:# BlueHost.com # .htaccess main domain to subdirectory redirect # Copy and paste the following code into the .htaccess file # in the public_html folder of your hosting account # make the changes to the file according to the instructions. # Do not change this line. RewriteEngine on # Change example.com to be your main domain. RewriteCond %{HTTP_HOST} ^(www.)?engradado.com$ # Change 'subdirectory' to be the directory you will use for your main domain. RewriteCond %{REQUEST_URI} !^/engradado/ # Don't change these line. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Change 'subdirectory' to be the directory you will use for your main domain. RewriteRule ^(.*)$ /engradado/$1 # Change example.com to be your main domain again. # Change 'subdirectory' to be the directory you will use for your main domain # followed by / then the main file for your site, index.php, index.html, etc. RewriteCond %{HTTP_HOST} ^(www.)?engradado.com$ RewriteRule ^(/)?$ engradado/ [L]
Here's my
rails_apps/engradado/public/.htaccess
:Options -MultiViews PassengerResolveSymlinksInDocumentRoot on #Set this to whatever environment you'll be running in RailsEnv production #RackBaseURI / #PassengerAppRoot /home2/engradad/rails_apps/engradado RackBaseURI /engradado SetEnv GEM_HOME /home2/engradad/ruby/gems
- Whenever I call a path helper, e.g.
root_url
ornews_path
, it prepends/engradado
to the path, so instead ofroot_url => "http://www.engradado.com/"
it printsroot_url => "http://www.engradado.com/engradado/"
, andnews_path(1) => "engradado/news/1"
instead ofnews_path(1) => "news/1"
.
How can I solve this so /engradado
isn't prepended to the url?