Doubt web.config

Asked

Viewed 73 times

0

I need you not to show the actual physical address on a link to download a file on my site.

The file link I want it to look like this: [Urlsite]/downloads/filename.

And I’m trying to use the following code on my web.config:

<rule name="Downloads Redirecionar">
    <match ignoreCase="true" url="^downloads/([a-zA-Z0-9_-]+).([a-zA-Z0-9_-]+)$" />
    <action type="Rewrite" url="/public/arquivosDownload/{R:1}.{R:2}" appendQueryString="false" />
</rule>     

But it’s not working. As if he didn’t use the rule. When I click to open a new tab the download link opens the page:

http://[Urlsite]/Downloads/filename.

without redirecting to:

http://[Urlsite]/public/fileDownload/filename.extensao

What I’m doing wrong that’s not working?

  • Is this really possible? Have you seen any post/tutorial explaining this?

  • So, worse than I don’t know if it is. They just told me here where I work that I have to do this scheme above. This was the first thing that went through my head, but I don’t know if it’s right.

1 answer

1


Maybe it’s the lack of stopProcessing, it is also necessary to remove the / from the front of /public, should look like this:

<rule name="Downloads Redirecionar" stopProcessing="true">
    <match ignoreCase="true" url="^downloads/([a-zA-Z0-9_-]+).([a-zA-Z0-9_-]+)$" />
    <action type="Rewrite" url="public/arquivosDownload/{R:1}.{R:2}" appendQueryString="false" />
</rule>
  • 1

    It worked out! Wow, but that anger, because a bar didn’t work out. And I made a lot of changes and that was it. But thank you for accompanying

  • @Renankaiclopes is because web.config already works as a "root" of the current folder, of course there may be variations in sub-folders, but for your case it works like this ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.