You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrestled with making this gem work with Webflow for a few days. Hopefully this will help someone do this in minutes.
Background:
We have a Rails 5 website on www.asdf.com (not the actual site), that is not hosted by Webflow. We use Cloudflare.
We have a blog that someone built on Webflow at asdf-blog.webflow.io (not the actual blog).
Goal
Make it so that www.asdf.com/blog points to asdf-blog.webflow.io. The url still shows as www.asdf.com/blog, but displays the content at asdf-blog.webflow.io.
Also, make it so that www.asdf.com/blog/posts/my-first-post (with /blog) still shows a url of www.asdf.com/blog/posts/my-first-post (with /blog), but displays the content at asdf-blog.webflow.io/posts/my-first-post (without /blog).
Hint
On Webflow, do not mess with changing slugs on Designer.
Just change the project settings under Hosting and Custom Code.
Step 3 - I did the following - installing the gem, adding the routes, and adding the controller.
In my Rails app, I installed this rails-reverse-proxy gem.
In routes.rb, I added:
get "/blog/*path", to: "blog#index"
get "/blog", to: "blog#index"
I added the controller:
# frozen_string_literal: true
class BlogController < ApplicationController
include ReverseProxy::Controller
BLOG_URL = "https://asdf-blog.asdf.com"
def index
reverse_proxy BLOG_URL, path: "/#{params[:path]}"
end
end
Step 4 - Two parts - on Webflow and on Cloudflare.
Step 4a - On the Webflow project settings, under the Hosting tab, I added a custom domain, asdf-blog.asdf.com aka BLOG_URL.
Step 4b - On Cloudflare, I arranged a rule to be set up, which is hinted at during Step 4a.
Type was CNAME.
Name was asdf-blog (the same subdomain as what I set up for the custom domain on Webflow project settings under Hosting).
Content was proxy-ssl.webflow.com.
Proxy status was DNS (a Proxy status of Proxied did not work at the time).
Step 5 - On Webflow project settings, under Custom Code, I set Href Prefix to /blog.
Step 6 - I clicked the Save Changes and the Publish button for the publish destinations, especially publishing to asdf-blog.asdf.com.
Note
The links on the Rails 5 website, asdf.com/blog (with a path that is prepended with /blog), will work because those requests will go through BlogsController, and the path is getting changed to /#{params[:path]} (removing /blog from the request to Webflow).
However, the links on asdf-blog.webflow.io and asdf-blog.asdf.com will not work because of the Href Prefix adding /blog to all links, but that doesn't matter in terms of the goals for making asdf.com/blog work. This is because requests made to Webflow directly will have /blog and will not have that request changed by BlogsController. Webflow will return a 404 because it doesn't know anything about /blog.
The text was updated successfully, but these errors were encountered:
I wrestled with making this gem work with Webflow for a few days. Hopefully this will help someone do this in minutes.
Background:
We have a Rails 5 website on
www.asdf.com
(not the actual site), that is not hosted by Webflow. We use Cloudflare.We have a blog that someone built on Webflow at
asdf-blog.webflow.io
(not the actual blog).Goal
Make it so that
www.asdf.com/blog
points toasdf-blog.webflow.io
. The url still shows aswww.asdf.com/blog
, but displays the content atasdf-blog.webflow.io
.Also, make it so that
www.asdf.com/blog/posts/my-first-post
(with/blog
) still shows a url ofwww.asdf.com/blog/posts/my-first-post
(with/blog
), but displays the content atasdf-blog.webflow.io/posts/my-first-post
(without/blog
).Hint
On Webflow, do not mess with changing slugs on Designer.
Just change the project settings under Hosting and Custom Code.
Steps
I followed the directions at https://university.webflow.com/article/href-prefix
For those steps:
Step 1 - This was already done.
Step 2 - I got someone to pay for the plan.
Step 3 - I did the following - installing the gem, adding the routes, and adding the controller.
In my Rails app, I installed this
rails-reverse-proxy
gem.In
routes.rb
, I added:I added the controller:
Step 4 - Two parts - on Webflow and on Cloudflare.
Step 4a - On the Webflow project settings, under the Hosting tab, I added a custom domain,
asdf-blog.asdf.com
akaBLOG_URL
.Step 4b - On Cloudflare, I arranged a rule to be set up, which is hinted at during Step 4a.
Type
wasCNAME
.Name
wasasdf-blog
(the same subdomain as what I set up for the custom domain on Webflow project settings under Hosting).Content
wasproxy-ssl.webflow.com
.Proxy status
wasDNS
(aProxy status
ofProxied
did not work at the time).Step 5 - On Webflow project settings, under Custom Code, I set
Href Prefix
to/blog
.Step 6 - I clicked the
Save Changes
and thePublish
button for the publish destinations, especially publishing toasdf-blog.asdf.com
.Note
The links on the Rails 5 website,
asdf.com/blog
(with a path that is prepended with/blog
), will work because those requests will go throughBlogsController
, and the path is getting changed to/#{params[:path]}
(removing/blog
from the request to Webflow).However, the links on
asdf-blog.webflow.io
andasdf-blog.asdf.com
will not work because of theHref Prefix
adding/blog
to all links, but that doesn't matter in terms of the goals for makingasdf.com/blog
work. This is because requests made to Webflow directly will have/blog
and will not have that request changed byBlogsController
. Webflow will return a 404 because it doesn't know anything about/blog
.The text was updated successfully, but these errors were encountered: