How to add a trailing_slash to all urls without in Rails 4?

Lucia

I've tried adding this in application.rb

config.action_controller.default_url_options = { :trailing_slash => true }

as well as having :trailing_slash => true in routes.rb

match '/download', to: 'welcome#download', via: 'get', :trailing_slash => true

But neither seems to work. I searched through rails 4.0 doc but couldn't find related info. What am I missing here?

Update:

I've tried adding

Rails.application.default_url_options[:trailing_slash] = true

in filter_parameter_logging.rb since this is the only place in the whole project where I could find Rails.application.*, but it's not working either. I found the line here among the releases and I am using 4.0.4. Am I adding this in the wrong place? And I did restarted server before rechecking.

And sorry for the simple question but from what I've gathered isn't trailing_slash supposed to be reflected in browser url as well, if not primarily? Because this is what I need, to go with historyjs.

complistic

I think you have the meaning of :trailing_slash => true wrong.

All it does is add the / to the end of you path helpers. No redirecting involved.

Your routes will still respond to both with and without the trailing slash.

If you want to redirect all non-trailing_slash uri's like /download to /download/ using a nginx http server you would do something like this:

rewrite ^([^.\?]*[^/])$ $1/ permanent;

You would still want to add the :trailing_slash => true to your routes so your path/url helpers generate the the correct uri's (so user don’t need to redirect).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to add a trailing_slash to all urls without in Rails 4?

From Dev

MVC - Make all URLs with a trailing slash 301 to URL without a slash?

From Dev

How to remove .php from all urls with no trailing slash?

From Dev

How to add specific code for all user profile urls - rails app

From Dev

How to add specific code for all user profile urls - rails app

From Dev

Redirect URLs without trailing slash to a different domain with trailing slash in .htaccess

From Dev

Rails 4: How do I add a column to ALL models in the application?

From Dev

How to add trailing slash with varnish?

From Dev

Formatting URLs in list to all have a trailing slash in python

From Dev

Add a trailing slash to URLs, using Tuckey's URL rewrite filter

From Dev

Add Trailing Slash to URLs - Development and Production Same Rules

From Dev

How to remove trailing slash from embedded Jetty URLs?

From Dev

How to copy URLs of all open Chrome tabs without an extension

From Dev

htaccess to route all requests through index add add trailing slash

From Dev

How can i display a certain attribute in a certain table without displaying all for a current user RAILS 4

From Dev

How to add redirect in htaccess for all urls not cotaining specific string?

From Dev

How do I route to a batman.js (batman-rails) controller in a rails 4 application without overwriting all other routes?

From Dev

Shortcut for including strong parameters in Rails 4 : without listing all fields

From Dev

Lower case urls and trailing slash

From Dev

Crawler4j, Some urls are crawled without issue while others are not crawled at all

From Dev

add an extra word to add all my URLs

From Dev

add an extra word to add all my URLs

From Dev

How to add validation in migration file (Rails 4)

From Dev

How to add sharing to individual entries - Rails 4

From Dev

how to make add this work with turbilinks rails 4

From Dev

how to make add this work with turbilinks rails 4

From Dev

How to redirect all URLs except one path and all its subpaths without mod_rewrite?

From Dev

How url works with or without trailing slash using htaccess

From Dev

Rails routing short urls without controller name

Related Related

  1. 1

    How to add a trailing_slash to all urls without in Rails 4?

  2. 2

    MVC - Make all URLs with a trailing slash 301 to URL without a slash?

  3. 3

    How to remove .php from all urls with no trailing slash?

  4. 4

    How to add specific code for all user profile urls - rails app

  5. 5

    How to add specific code for all user profile urls - rails app

  6. 6

    Redirect URLs without trailing slash to a different domain with trailing slash in .htaccess

  7. 7

    Rails 4: How do I add a column to ALL models in the application?

  8. 8

    How to add trailing slash with varnish?

  9. 9

    Formatting URLs in list to all have a trailing slash in python

  10. 10

    Add a trailing slash to URLs, using Tuckey's URL rewrite filter

  11. 11

    Add Trailing Slash to URLs - Development and Production Same Rules

  12. 12

    How to remove trailing slash from embedded Jetty URLs?

  13. 13

    How to copy URLs of all open Chrome tabs without an extension

  14. 14

    htaccess to route all requests through index add add trailing slash

  15. 15

    How can i display a certain attribute in a certain table without displaying all for a current user RAILS 4

  16. 16

    How to add redirect in htaccess for all urls not cotaining specific string?

  17. 17

    How do I route to a batman.js (batman-rails) controller in a rails 4 application without overwriting all other routes?

  18. 18

    Shortcut for including strong parameters in Rails 4 : without listing all fields

  19. 19

    Lower case urls and trailing slash

  20. 20

    Crawler4j, Some urls are crawled without issue while others are not crawled at all

  21. 21

    add an extra word to add all my URLs

  22. 22

    add an extra word to add all my URLs

  23. 23

    How to add validation in migration file (Rails 4)

  24. 24

    How to add sharing to individual entries - Rails 4

  25. 25

    how to make add this work with turbilinks rails 4

  26. 26

    how to make add this work with turbilinks rails 4

  27. 27

    How to redirect all URLs except one path and all its subpaths without mod_rewrite?

  28. 28

    How url works with or without trailing slash using htaccess

  29. 29

    Rails routing short urls without controller name

HotTag

Archive