如果您将博客设置为root并且只​​想显示域,如何更改RefineryCMS应用程序中URL的“/ blog”?

时间:2013-09-05 00:51:07

标签: ruby-on-rails routing refinerycms

我已将博客设为根目录。然后按照http://refinerycms.com/guides/page-titles-and-urls上的教程说明要更改Refinery的默认slug,我需要修改config/initializers/refinery/pages.rb以获得config.use_custom_slugs = true。那部分已经完成。

我的博客将会发布类似于blog.example.com的子域名,因此如果我有blog.example.com/blog

那么它看起来很糟糕

所以我已经确保将“主页”重定向到www.example.com,所以现在我需要知道如何从网址中删除/blog。点击“博客”即可转到blog.example.com

在高级选项中,我尝试将自定义slug设置为“/”,但是没有按预期工作。

enter image description here

3 个答案:

答案 0 :(得分:2)

您需要更改routes.rb文件以重定向到博客索引页面。确保在安装Refinery Core Engine之前放置它。

Yourapp::Application.routes.draw do

root :to => 'refinery/blog/posts#index'

# This line mounts Refinery's routes at the root of your application.
# This means, any requests to the root URL of your application will go to Refinery::PagesController#home.
# If you would like to change where this extension is mounted, simply change the :at option to something different.
#
# We ask that you don't use the :as option here, as Refinery relies on it being the default of "refinery"
mount Refinery::Core::Engine, :at => '/'
...

答案 1 :(得分:1)

Refinery Blog引擎初始化程序有一个“page_url”选项,您可以更改。

取消注释config / initializers / refinery / blog.rb中的以下行:

# config.page_url = "/blog"

并将其更改为

config.page_url = "/"

不确定这是否适用于自定义子域,但这是如何替换默认的'/ blog'路径

答案 2 :(得分:0)

我并不熟悉炼油厂的内部,但请尝试将其放在您的routes.rb文件的顶部:

get '/', to: redirect('/blog')

这应该允许您使用您想要的域,但我相信它会在呈现之前重定向到/blog

相关问题