Rule Rewrite Changing script directories

Asked

Viewed 87 times

1

I have the following problem, when using the Rule below my default directory is changed and mine js scripts and files css stop working.

<rule name="Produtos Detalhe">
   <match url="^(produto)\/(.*)\/(.*)\/?$"  />
   <action type="Rewrite" url="/Produto/Detalhe?id={R:3}"  />
</rule>

Example, this code:

<link href="@Href("~/Content/Site/css/bootstrap.min.css")" rel="stylesheet">

It’s getting like this after rendered:

<link href="/produto/Content/Site/css/bootstrap.min.css" rel="stylesheet">

I’d like you to stay:

<link href="/Content/Site/css/bootstrap.min.css" rel="stylesheet">
  • Have you tried to take the tilde of this instruction? @Href("~/Content/Site/css/bootstrap.min.css")

1 answer

0

It’s simple. Your Rule is as a general rule, at the base, the product directory. as you can see yourself, everything and any url you use will automatically always have this.
Try to create a universal rule.
And with the collected data you try to know where you are going in the system, if it is for products you ai yes, use dir /products and otherwise /.
I did it in apache but in Asp I do not know.
I’m just trying to give you a light.

Try to keep it that way: ^(.*)\/(.*)\/?$ and then you create code rules the part to know if you are in the right products.

Browser other questions tagged

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