Shpigford
Shpigford

Reputation: 25338

301 redirect by replacing character in URL?

Somehow Google has indexed the wrong URL. No idea how, but alas, here we are.

I need to forward all URLs with this setup...

example.com/features.reports to example.com/features/reports

The constant here is the domain and "features"...basically anything with features. should forward to features/

How can I set that up in routes?

Upvotes: 0

Views: 108

Answers (1)

Jonathan Tran
Jonathan Tran

Reputation: 15276

Try this:

match "/features.*path" => redirect("/features/%{path}")

This will return a 301 permanently moved redirect.

See Rails Guides for more info on redirect and globbing.

Upvotes: 2

Related Questions