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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:37:49+00:00 2026-05-23T23:37:49+00:00

I am trying to create a condition to rewrite a url from http://subdomain.example.com/foo/foofile.txt to

  • 0

I am trying to create a condition to rewrite a url from http://subdomain.example.com/foo/foofile.txt to http://example.com/foo/foofile.txt when the request has foo/foofile.txt in it. If someone could point me in the right direction, I would appreciate any and all help…

Thanks in advance,
B

  • 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-23T23:37:50+00:00Added an answer on May 23, 2026 at 11:37 pm

    This is redirecting a specific subdomain to the main domain, for a specific file.

    Which version of isapi_rewrite are you using, v2 or v3?

    This assumes v3:

    RewriteCond %{HTTP:Host} ^subdomain\.(.*)$
    RewriteRule ^(/foo/foofile3\.txt)$ http://%1$1 [NC,R=301]
    

    The RewriteCond tests for a host beginning with subdomain (and a dot), and captures the remaining (example.com) for convenience in the rewrite rule. You could also put the specific example.com in there, but this keeps it more generic.

    The RewriteRule then looks for a specific /foo/foofile3.txt, and captures it (again for convenience of not repeating it in the rule). The result has %1 for the capture up in the condition (example.com) and $1 for the capture in the rule (/foo/foofile3.txt)

    The NC is not case-sensitive, the R=301 is a permanent redirect.

    With v3, querystring parameters are automatically handled, so this keeps any that are after the file.

    Other possibilities that make it a little more complex are any subdomain at all, or filename patterns instead of the one specific file.

    I was having trouble with the browser caching my attempts while getting the rule right. So even though I changed the rule, the browser had cached my previous redirect. My quick fix was to count up the filename for new urls: foofile2, foofile3 (I guess I got it on the 3rd try…). I could have cleared the browser cache each time too; this was quicker.

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

Sidebar

Related Questions

I'm trying to create a rewrite condition in .htaccess file to check if url
I'm trying to create an conditional Rewrite Rule using an .htaccess file and Apache.
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I am trying to create a rawcontact in android that has a specific contact
Trying to create code section within an If condition throws error: Unexpected section keyword
i'm trying to create an application with Windows Phone 7, which displays data from
I'm trying to create a class with a built-in condition for one of its
I'm trying to create one entity from 2 tables that are related not by
I am trying to reproduce a threading error condition within an HTTP Handler. Basically,
Trying to create a pattern that includes an or condition. $pattern[body]='/(<\/a><\/li><\/ul><\/div><p>|<h2>)(.*)<div class=like>/s'; The pattern

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.