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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:54:53+00:00 2026-05-27T02:54:53+00:00

The Setup My setup is to have resources shared for two or more sites

  • 0

The Setup

My setup is to have resources shared for two or more sites that have similar structures though different content. In example…

http:// localhost/site1/
http:// localhost/site2/

The rewrite rules are intended to add exceptions for the shared resources. In example the scripts folder (and of course everything inside of it) is rewritten so…

http:// localhost/scripts/

…is accessible at…

http:// localhost/site1/scripts/
http:// localhost/site2/scripts/

The Problem

When trying to access…

http:// localhost/site1/scripts/admin.js

…the following rewrite applies via the current rule and tries to rewrite it to the admin directory…

RewriteEngine on
RewriteRule .*/admin(.+) admin$1 [QSA] #Messes with scripts/admin.js

I think this is a directory depth issue, where the rule .*/ can apply to more than the first directory (site1/) and also inherently (and undesirably) applies to all directory depths (e.g. depth1/depth2/depth3/ etc).

Desired Outcome

How do I adjust this rule so that…

  1. The admin index (site1/admin/) is caputed by this rule.
  2. The admin JavaScript file (site1/scripts/admin.js) is ignored by this rule.
  3. We keep the dynamic starting bit of the rule (RewriteRule .*/admin) so no matter the name of the directory that is used Apache will continue to automatically just work or we can modify it to have the same effect but the end result is that it must remain dynamic.
  4. I do not rename admin.js as it would be cheap and thus I won’t learn from this.
  • 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-27T02:54:54+00:00Added an answer on May 27, 2026 at 2:54 am

    A couple of things you can try depending on how you have everything else working. If the site1/scripts/admin.js exists and you want to have URI’s that access existing files (like scripts, or images) not to be rewritten, you can try adding this right before the RewriteRule:

    RewriteCond %{REQUEST_FILENAME} !-f
    

    Or, you can also just make it so scripts won’t get rewritten by adding this right before the RewriteRule:

    RewriteCond %{REQUEST_URI} !\.js$
    

    Requests that end with .js will fail that condition and the rule will not be applied. Alternatively, you can narrow it down specifically to admin\.js or scripts/[^\.]+\.js (replacing the \.js in the condition).


    Can we LIMIT the directory depth of the rule then?

    You can if you use [^/]+ instead of .*.

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

Sidebar

Related Questions

The Setup My setup is to have resources shared for two or more sites
I have two django sites that use the same database and share some of
Setup I have a website that draws RSS feeds and displays them on the
Setup: I have a COM DLL that calls a method inside a managed C#
I have a site that is hosted in shared hosting environment. They use a
I have a client/server type application setup, similar to a bittorrent downloading program. However,
I have a table setup as follows: +---------------+ | resources | +---------------+ | id
I have setup a model structure which allows different models to associate with a
I have a TabActivity that has a TabHost with two tabs. Each tab has
So basically I have two models, Entry and Comment. I have the association setup

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.