开发者

Ruby on Rails wildcard routing such as /foo.htm /foo.php /foo.something

开发者 https://www.devze.com 2023-01-04 02:41 出处:网络
I\'m trying to create a routing situation where by default, any URL\'s such as this: /foo /something /foo.php

I'm trying to create a routing situation where by default, any URL's such as this:

/foo

/something

/foo.php

/somethingelse.xml

/something.something.else

etc.

will all route to one controller, assuming they don't route anywhere else.

i can get this to work with the following code in my routes:

map.myroute '/:file_or_folder', :controller => 'mycontroller'

this works fine as long as there are no dots in the URL:

/something

but this 开发者_运维知识库wont work:

/something.foo

any ideas?


Dots are not allowed by default. You can specify a regex for what file_or_folder can match, such as this:

map.myroute '/:file_or_folder', :controller => 'mycontroller', :file_or_folder => /.*/
0

精彩评论

暂无评论...
验证码 换一张
取 消