Mask url path on IIS server

Asked

Viewed 1,846 times

1


I’m having a question in which I need but show a path in the url that is more user friendly, like this:

http://hexatasistemas.com.br/sites/mercedita/efetuarlogin.asp

I wish instead of showing all this way just to show

http://hexatasistemas.com.br/mercedita/

Just like in that website by clicking on a link in the menu.

Obs: My server is Windows with IIS, and does not work the .htaccess nor the mod_rewrite that are for Apache. Thank you in advance, and in case you have not understood or have any doubts just comment.

  • This can be solved with a route structure, which can be done in several ways, depending on the technologies you are using.

  • I am programming this site in Asp. I saw something about a file . htaccess but I could not understand anything.

  • Wallace, this link of yours works with apache and it doesn’t work on mine because it’s IIS. I will edit my question specifying this.

1 answer

3


Using htaccess is possible to do

<IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteRule ^mercedita/?$ /sites/mercedita/efetuarlogin.asp [NC,L]
</IfModule>

So when there is /mercedita after .com.br the server will understand that it is the same thing as /sites/mercedita/efetuarlogin.Asp

Here you will be able to understand a little better about the operation http://blog.thiagobelem.net/aprendendo-urls-amigaveis

For ASP IIS add the following code in your web.config within the tag <system.webServer>:

<rewrite> 
  <rules> 
    <rule name="renomelogin" stopProcessing="true"> 
      <match url="^mercedita$" ignoreCase="true" /> 
      <conditions logicalGrouping="MatchAll"> 
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="/sites/mercedita/efetuarlogin.asp" appendQueryString="true" /> 
    </rule> 
  </rules> 
</rewrite>

Note: If the person type mercedita/ the page will not be found, for this you should add one more rule(<rule>) with a different name and change the line

    <rule name="renome login com barra" stopProcessing="true"> 
      <match url="^mercedita/$" ignoreCase="true" /> // Adicione a barra no final
  • Asp is usually under IIS.. htaccess is apache

  • I saw his comment saying that he could not use htaccess and gave an example, but thanks, I did not know that htaccess does not work with Asp, I always used in php / apache

  • At the root of my server I found a file web.config can you use it?

  • How you are using Asp read this tutorial and see if it helps, http://www.devmedia.com.br/conceitos-e-exemplo-url-amigaveis-em-asp-net/23270

  • It didn’t work @Leo. Mine is classic Asp and this is Asp.Net

  • This tutorial teaches how to do by web.config, take a look http://www.rafaelwendel.com/2011/10/url-friends-no-iis/ @Brunoromualdo

  • I had already taken a look at this site but I could not understand where to change to apply in my example. You could change your answer with an example?

  • I added the code, test there if it works, do not understand about ASP

Show 4 more comments

Browser other questions tagged

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