sailorproject / sailor

A Lua MVC Web Framework.
MIT License
921 stars 125 forks source link

Question: How do I define an arbitrary URL #112

Open xspager opened 8 years ago

xspager commented 8 years ago

I'm wondering if it is possible to have a controller to respond to a URL like /books/2016/03/22/new_book, for what I checked it end up running the action index and passig parameters like ?2016=03&22=new_book

m1cr0man commented 8 years ago

Yes, the new Regex I wrote for matching friendly URLs on Nginx does what you would expect.

However, if you don't want to make every URL behave this way (as that config would cause) I suspect you would be stuck to rewriting the URL serverside in your controller.

Etiene commented 8 years ago

that would depend on the webserver you are using. If you are using apache, for example, you would have to edit the .htaccess file at the root dir of the app and change the regex there.

Etiene commented 8 years ago

ping! Did you succeed with this?

xspager commented 8 years ago

Oh, sorry for not answering earlier :( I just gave up using the format I wanted for the URL for now.

I have a problem with relying on the webserver to support more complicated URLs, if for example I wanted to go from Apache to Nginx I would need to rewrite the rules by hand. Would be nice if Sailor itself could handle the "complex" URLs or provided a tool to generate a config file or fragment to a particular webserver from a common format (Lua code/config?)

Etiene commented 8 years ago

This has yet to be implemented :x

Maybe we need a generator?