我正试图在Bluehost上build立一个Rails网站,而且我在path助手方面遇到了麻烦。 由于我不想猴子补丁Rails,我试图通过.htaccess来解决这个问题。 这是一个场景:
public_html/engradado www.engradado.com上托pipewww.engradado.com ,指向rails_apps/engradado/public 我正在通过这个public_html/.htaccess文件重写www.engradado.com指向www.engradado.com/engradado :
# 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]
这是我的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
root_url或news_path ,它/engradadopath/engradado ,而不是root_url => "http://www.engradado.com/"它会打印root_url => "http://www.engradado.com/engradado/"和news_path(1) => "engradado/news/1"而不是news_path(1) => "news/1" 。 我怎样才能解决这个/engradado是不是/engradado的url?