你好我使用High Voltage在鐵軌我的靜態頁面,但我看到了一個結構時,我讓我的靜態網頁:刪除網頁/網頁靜態軌道
myserver.com/ 頁 /約
myserver.com/ 頁 /隱私
myserver.com/ 頁 /項 。
。
。
。
我不想那「頁」單詞出現。我想出現這種結構
myserver.com/about
myserver.com/privacy
myserver.com/terms
非常感謝你。問候!
你好我使用High Voltage在鐵軌我的靜態頁面,但我看到了一個結構時,我讓我的靜態網頁:刪除網頁/網頁靜態軌道
myserver.com/ 頁 /約
myserver.com/ 頁 /隱私
myserver.com/ 頁 /項 。
。
。
。
我不想那「頁」單詞出現。我想出現這種結構
myserver.com/about
myserver.com/privacy
myserver.com/terms
非常感謝你。問候!
看到this bug
這可能工作:
match '/:id' => 'high_voltage/pages#show', :as => :static, :via => :get
編輯:
當你使用上面的說明,您還需要經過你的意見,改變的所有實例:
page_path(:id=>:about)
去:
static_path(:id=>:about)`
或更好,但剛:
static_path(:about)
那麼找到你的看法所有的link_to的,讓上面的改變...您的網址將不再有字頁在他們
希望這有助於
這個工作對我來說:
match '*id', :to => 'high_voltage/pages#show'
通過將以下內容添加到config/routes.rb文件中,您可以刪除URL的「/ pages」部分。
match '/*id' => 'high_voltage/pages#show', :as => :static, :via => :get
「*」將允許支持嵌套目錄。
然後,您可以創建指向app/views/pages/en/test.html的鏈接「/ en/test」。erb如下:
<%= link_to "Test", static_path("en/test") %>
要完成您的半靜態設置,您不妨考慮2件事。
1)一些基本的路由(放置之前的路徑線以上)爲默認內容目錄(根據需要)
root :to => 'high_voltage/pages#show', :id => 'index' # map root to 'index.html'
match '/en' => 'high_voltage/pages#show', :id => 'en/test' # map '/en' to '/en/test.html'
2)一個很好的SEO重定向,以去除任何多餘的尾隨斜槓:http://nanceskitchen.com/2010/05/19/seo-heroku-ruby-on-rails-and-removing-those-darn-trailing-slashes/
根據documentation,現在可以通過將以下代碼添加到high_voltage初始值設定項來完成此操作。我已經在使用2.4版本的gem的rails 4+中成功地使用了它。
# config/initializers/high_voltage.rb
HighVoltage.configure do |config|
config.route_drawer = HighVoltage::RouteDrawers::Root
end
不要工作:(,我檢查這個補丁對我來說,但不工作的罰款我的鏈接_footer.html.erb具有這種結構 <%=的link_to 「關於」,page_path(:ID =>。 「約」)%> 我看到了我的頁腳鏈接但這種結構 myserver.com/pages/about, myserver.com/pages/privacy, myserver.com/pages/terms 謝謝! – hyperrjas
我會更新我的答案更多說明,這是行不通的,我現在正在使用它:) – stephenmurdoch
好吧,我起來約會我的回答。請記住儘可能將路線儘可能靠近routes.rb的底部,這似乎有助於防止其他問題在 – stephenmurdoch