[英]Browser control NavigateToString display HTML code instead of rendering page
[英]Ruby On Rails: Display html source code instead of rendering it
我有一个大问题(即使我服务器的管理员似乎也很难解决它)。
我使用cpanel(11.25.0-STABLE)在rails应用程序上创建了一个新的ruby,在访问其原始uri(带有端口号)时可以正常工作。
为了使该uri更加“用户友好”,我创建了一个重写程序以访问RoR应用程序而不显示端口号。
我重写的uri的.htaccess内容
RewriteEngine on
RewriteCond %{HTTP_HOST} ^greendeers.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.greendeers.com$
RewriteRule ^.*$ "http\:\/\/127\.0\.0\.1\:12001%{REQUEST_URI}" [P,QSA,L]
app / controllers / helloworld_controller.rb
class HelloworldController < ApplicationController
def index
end
end
app / views / layouts / helloworld.html.erb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title><%= controller.controller_name %>: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
</head>
<body>
<p style="color: green"><%= notice %></p>
<%= yield %>
</body>
</html>
app / views / helloworld / index.html.erb
<h1>HELLO WORLD</h1>
第一页(由RoR创建的原始页面)在两个uri上都可以正常工作,但是在访问我的一个控制器时,不会呈现html,而是显示html代码。
http://www.greendeers.com/helloworld
此页面使用原始uri进行了预期的渲染(与上面相同,端口号:12001)
访问两个uri时,我的日志显示相同的内容:
正在处理HelloworldController#index(用于[我的IP地址]在2010-07-10 02:53:20)[GET]
布局/ helloworld中的渲染模板
渲染helloworld / index
1ms内完成(查看:1,DB:0)| 200 OK [ http://greendeers.com/helloworld]
您是否有解决方法的线索?
抱歉,目前我只能为每个帖子发布一个链接:/
这是因为您严重使用了.htaccess。
请改用代理系统或乘客。 不是您的重写规则
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.