forward slash in url rule parameter

Hi,

I have a controler ImageController with 3 actions view, restrict, thumbnail

Each action accept a parameter filePath which is the path to the image to be rendered

The server is Apache.

I define the following url rule


'image/<action:(view|restrict|thumbnail)><filePath>' => 'image/<controller>,

using the following url fails:


domain.ext/image/view/admin%2Fbanner%2Fbanner001.jpg

as well as


domain.ext/image/view/admin/banner/banner001.jpg

but




domain.ext/image/view/admin*banner*banner001.jpg 

succeeds

Of course, I could use the * char (or any other char) and change it into / in the controller, but it’s not very satisfying.

My question is how could I use the forward / in parameter values ?

Last Edit:

in fact I was misled by permissions in controller

The problem is slightly different. It works with / in the parameter but not when the / is urlencoded (%2F). It means that when using Url::to, the produced URL doesn’t work.

Hi,

If nothing works then simply use base64 encode / decode for file path.

OR

Have u tried the traditional way?




domain.ext/image/view?filePath=admin%2Fbanner%2Fbanner001.jpg



Because pretty URL meant segregating the query strings by "/" .

I hope somewhat my suggestion helped you.

Thank you for answer.

Apparently it works with traditional Url (not pretty) after removing the rules

But I cannot use pretty Url in this case

Hi,

If you cannot use traditional URL, I suggest to use base64 encode / decode the filePath

You can make use of the JS -> https://developer.mozilla.org/en/docs/Web/API/WindowBase64/Base64_encoding_and_decoding , in case needed confusion in client side for encoding and decoding.