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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:58:50+00:00 2026-05-19T12:58:50+00:00

Question: What ruleset do I need to do the following redirects: [1] http://www.xyzblog.com/foo/bar.php =>

  • 0

Question:

What ruleset do I need to do the following redirects:

[1] http://www.xyzblog.com/foo/bar.php  => htdocs/projects/xyzblog/foo/bar.php
[2] http://www.xyzblog.com/js/jquery-min.js => htdocs/js/jquery-min.js

[3] http://www.bigcommerce.ch/images/baz.png => htdocs/projects/bigcommerce/images/baz.png
[4] http://www.bigcommerce.ch/css/reset.css => htdocs/css/reset.css

In [2] and [4] the requested file does exist in the original path, so no redirect takes place.

Background:

I have a WAMP envo which uses Apache Friend’s excellent XAMPP. I work on multiple projects for different clients and have set up the following directory structure:

htdocs
  + css
  + images
  + includes
  + js
  + projects
     + bigcommerce
     + xyzblog
     ...

When I start working on a new project I create a directory with the same name under projects; moreover, I name the project after the host name of the client. So if I start working on a project where the production site would be http://www.dreamvacation.com I add a dreamvacation directory under the projects directory.

Lastly I temporarily, add the following line to my hosts file in C:\WINDOWS\system32\drivers\etc

127.0.0.1   dreamvacation.com

That way all requests to dreamvacation.com would be short circuited to my localhost.

I still need one component to be able to code on localhost and expect it to behave the same way when uploaded to the production server. That is an htaccess file to check what the host name is in the request and redirect to a directory with the same name less the top domain identifier (.com, .net, etc). The redirection should only take place if the requested file does not exist. This last condition is there because I place frequently used files in directories under htdocs – for instance I only have one jquery-min.js in htdocs/js and only one blueprint css in htdocs/css/blueprint/screen.css. However each project also has a js, css, … subdirectory but only for project-specific files.

How could this be achieved?

  • 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-19T12:58:51+00:00Added an answer on May 19, 2026 at 12:58 pm

    You should certainly have a look at named based virtualhosts. Starting the directory root on each client directory. This is the real solution 🙂

    For your shared folers you could use “Alias” instructions in these Virtualhost so that some directories would always target the same places on the directory tree.
    and use links to share your shared folders.

    Anyway you can do on your own way as well. It something used for Mass Virtual Hosting, where writing thousands of Virtualhosts is a pain, mode_rewrite is a good replacement solution.

    To detect exisiting files and directories you can use the RewriteCond directives and prevent the rewriting if the file exists.
    Then on the real rewrite you need to reuse the apache variable %{HTTP_HOST}. So, I did not test it but something like that should be a good starting point (user RewriteLogLevel and RewriteLog to debug),:

    RewriteEngine On
    RewriteBase /
    RewriteCond   %{REQUEST_FILENAME} !-f
    RewriteCond   %{REQUEST_FILENAME} !-d
    RewriteCond   %{HTTP_HOST}                 ^www\.[^.]+\.com$
    RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
    RewriteRule   ^www\.([^.]+)\.com(.*) /htdocs/projects/$1$2
    

    This is based on apache documentation examples for username based domains, you should check this apache doc page for “Mass Virtual Hosting” for more details, but some of the example includes file-based rules and checks that you do not need on your dev env. Remember using VirtualHosts without mod_rewrite is certainly easier but mod_rewrite can do quite everything if you want.

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

Sidebar

Related Questions

The webpage is here: http://develop.macmee.com/testdev/ I'm talking about when you click the ? on
Question: I need to read a CSV file. I use the FileHelpers library to
Question is self explanatory, again I need an alternativs in cocos2d android to use
Question for the video tag, the following code works for every browsers expect opera
Question i asked earlier along the same lines - jQuery - Selecting a child
Question 1: I've tried the following to detect characters (uppercase and lowercase), numbers and
Question I need to make a short write to a file every 15 seconds
Question How can I remove empty xml tags in PHP? Example: $value1 = 2;
Question How do you modify a value in a PHP array if you do
Question What's the full code to enable jQuery on a page and then use

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.