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 4002338
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:00:54+00:00 2026-05-20T08:00:54+00:00

Searched for a few hours with no avail so here goes… I have a

  • 0

Searched for a few hours with no avail so here goes…

I have a domain which is receiving quite a few hits per day and have been asked if I can serve the static content from a subdomain. As the site is quite extensive and already written, I was wondering if there is any way I can use URL rewriting to change:

http://www.example.com/image.gif

to

static.example.com/image.gif

I have a solution which works using 301 redirects but from what I understand, this is counter productive as 2 requests will have to be made per image. I don’t really want to go through all the aspx pages and css to hard code the new url as it will cause problems further down the line – some parts of the site are still being developed and static content could change at any time. I tried using rewrite (as opposed to redirect) to change the url but it came out something like:

http://www.example.com/http://static.example.com/image.gif

How would you achieve this? I have full access to dns and the server (win 2008r2 / IIS 7.5) so can make any changes if url rewriting is not the answer.

Thanks in advance

Tom.

  • 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-05-20T08:00:54+00:00Added an answer on May 20, 2026 at 8:00 am

    You can accomplish this using an HttpModule. The following example captures all requests for gif files, and changes the absolute path to point to your alternate site that hosts the static content. Try this method inside of a HttpModule:

        private void Application_BeginRequest(Object source, EventArgs e)
        {
            // Create HttpApplication and HttpContext objects to access
            // request and response properties.
            HttpApplication application = (HttpApplication)source;
            HttpContext context = application.Context;
            string filePath = context.Request.FilePath;
            string fullPath = context.Request.Url.AbsoluteUri;
            string fileExtension = VirtualPathUtility.GetExtension(filePath);
            if (fileExtension.Equals(".gif"))
            {
                context.Response.ContentType = "image/gif";
                context.Response.Redirect(fullPath.Replace("www.example.com", "static.example.com"));
            }
        }
    

    For more about HttpModule, go here: http://msdn.microsoft.com/en-us/library/ms227673.aspx

    I tested the above code – it works. I hope this helps.

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

Sidebar

Related Questions

This is quite a noobish question, I have searched for a few hours now
I Have searched for a few hours on google and on here. I have
After reading Eric Evans' Domain driven Design I have a few questions. I searched
I've searched this for a few hours already, but it doesn't work. I have
I have searched and read for a few hours yet I still cant understand
I have searched for a few hours already but have found nothing on the
I've searched quite a bit and found a few solutions that did not end
I have searched and found a few image scaling libraries for Java. But not
I am writing some JSP 2.x tag files. I have searched for a few
I searched for few hours. Most of the flash uploaders are php based. I

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.