URL redirection via web.config

Asked

Viewed 998 times

0

I need to perform a page redirect http://exemplo/comunicacao/ to the page http://exemplo/caminho_novo/comunicacao.

I’m performing the following on web.config :

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
       <defaultDocument>
            <files>
                <add value="index.aspx" />
            </files>
        </defaultDocument>
      <httpRedirect enabled="true" destination="/caminho_novo/comunicacao$Q" httpResponseStatus="Permanent" />    

   </system.webServer> 
</configuration>

So far so good, but the problem is that the staff is calling the page already with parameters filled, and after the path /comunicacao I have a asp called exibe.asp that receives parameters to display content.

Doing so as it is configured in web.config, to url comes mounted as follows : exemplo/caminho_novo/comunicacao/?id=136923/exibe.asp

inserir a descrição da imagem aqui

That is, the parameter is coming before the page asp, sure would be :

exemplo/caminho_novo/comunicacao/exibe.asp?id=136923

Can someone help me?

2 answers

1


Failed to add the $V, which is the path of the url with page before the $Q which is the querystring, the exactDestination="true", that informs that it will be an absolute and not relative path:

<httpRedirect enabled="true" 
              destination="/caminho_novo/comunicacao$V$Q" 
              exactDestination="true"
              httpResponseStatus="Permanent" />
  • Ricardo worked! Just had to use httpRedirect enabled="true" destination="/presencial$V$Q" &#xA; exactDestination="true"&#xA; httpResponseStatus="Permanent" /> What I didn’t understand very well was the use of exactDestination="true".

1

The $Q just introduces the querystring, I have no idea who’s introducing the.Sp display in front of everything. There are several variables you can use to build your URL with Httpredirect as it says on the Microsoft reference page.

https://msdn.microsoft.com/en-us/library/ms525695%28v=vs.90%29.aspx? f=255&Mspperror=-2147217396

Give me ideas that you’re putting the $Q before the page name.

Passes the requested URL, without the server name and without any Parameters. To include Parameters, use the $P or $Q variable with the $V variable.

Experiment with the example in the documentation, such as: /way_new/communication$S$Q

  • Thank you, it served me too!

Browser other questions tagged

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