Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9057961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:35:57+00:00 2026-06-16T14:35:57+00:00

I am using IIS url rewriting module in asp.net application, my problem is any

  • 0

I am using IIS url rewriting module in asp.net application, my problem is any internal relative references like js, css, images are now pointing to wrong url after this url rewrite, below is my rewriting rule

<rewrite>
      <rules>
         <rule name="pk" patternSyntax="ECMAScript">
          <match url="pk/([a-z]+).aspx" />
          <action type="Rewrite" url="{R:1}.aspx?mid=1" />
          <conditions logicalGrouping="MatchAny">
            <add input="{REQUEST_FILENAME}" pattern="(\.css|\.js)$" negate="true" />
          </conditions>
        </rule>
      </rules>
</rewrite>

In above rewrite any url with “pk/page_name.aspx” is being translated to page_name.aspx?mid=1, this is working fine, however references to js,css and images in master page are now also pointing to “pk/files/js/jquery.js” while in my application it should be “files/js/jquery.js”, Please help me solve this issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:35:59+00:00Added an answer on June 16, 2026 at 2:35 pm

    I am able to solve this issue by myself, Earlier i was doing it completely wrong, I was doing just a rewrite which is causing problem, I solved this by first “Redirecting” the page to the desired URL and then “Rewriting” that URL to the one which my application understand. Following are my configuration

    <rewrite>
          <rules>
            <rule name="Redriect for Markets" stopProcessing="true">
              <match url="([a-z]+)\.aspx" />
              <action type="Redirect" url="/{id:{C:1}}/{R:1}.aspx" appendQueryString="false" />
              <conditions>
                <add input="{REQUEST_FILENAME}" pattern="(\.css|\.js|\.jpg|\.png|\.woff|\.tiff|\.gif|\.dev|\.swf)$" negate="true" />
                <add input="{QUERY_STRING}" pattern="mid=(.+)" />
              </conditions>
            </rule>
            <rule name="Rewrite for Markets" stopProcessing="true">
              <match url="([a-z][a-z])/(.*)" />
              <action type="Rewrite" url="{R:2}?mid={marketId:{R:1}}" />
              <conditions logicalGrouping="MatchAny">
                  <add input="{REQUEST_FILENAME}" pattern="(\.css|\.js|\.jpg|\.png|\.woff|\.tiff|\.gif|\.dev|\.swf)$" negate="true" />
              </conditions>
            </rule>
          </rules>
          <rewriteMaps>
            <rewriteMap name="id">
              <add key="1" value="pk" />
            </rewriteMap>
            <rewriteMap name="marketId">
              <add key="pk" value="1" />
    
            </rewriteMap>
          </rewriteMaps>
    
        </rewrite>
    

    After doing this my URL which is like https://www.mydomain.com/index.aspx?mid=1 is first “Redirected” to https://www.mydomain.com/pk/index.aspx and then “Rewritten” to https://www.mydomain.com/index.aspx?mid=1 internally. So my browser window show URL as https://www.mydomain.com/pk/index.aspx and value I get in Request.QueryString[“mid”] is 1, which is exactly what i wanted.

    One thing more for internal URLs to work I have to take the base URL in master page currently it is set to “/”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm programming ASP.NET using visual studio 2010 and IIS 7.5 I have URL-rewriting in
I am using UrlRewriting.Net for url rewriting in Asp.Net 2 and IIS 5.1 (offline)
I'm using the URL Rewriting.NET tool with IIS 6. I've got my default page
I have a ASP.NET 4.0 web forms application (IIS 7) where I am using
I'm using Intelligencia url rewriting currently but have just leased an IIS 7.5 server
I am implementing URL rewriting in ASP.net and my URLs are causing me a
I'm using url rewriting.net. I'm testing web on the local host, it is successfully
I've been having an issue with URL Rewriting and Postbacks. Edit: Currently using IIS
I have a current system using IIS 6 and 7, written in ASP.NET with
When I deploy an ASP.NET MVC3 application to an IIS 7.5 on WindowsServer 8RC2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.