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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:28:50+00:00 2026-05-28T01:28:50+00:00

I need to prevent second directory depth or deeper placed strings from matching first

  • 0

I need to prevent second directory depth or deeper placed strings from matching first directory depth rules with multi-domain support thrown in for extra chaos. Besides this issue everything is working fine. I need to make some clarifications first.

The page having trouble is when I have the string ‘blog’ (without the quotes) in the URL at dir2 or deeper though I only want it to match dir1.

Visual of directory depth…

localhost/example.com/dir1/dir2/dir3/

I have multi-domain support, essentially multiple websites share the same modules (modules being blog/, forums/, messages/, etc). Each site has it’s directory in the same directory as the modules (/dir1/website1/ is in the same directory as dir1/blog/). Essentially either you visit a set module (blog/, forums/, messages/) which are rewritten to or if a module does not match it gets rewritten to the main index file.

What is happening is that…

admin/templates/blog

…is matching…

blog/

I have tried using the ^starts with operator though the problem is that due to the multi-domain support I have to transverse two directories to begin with.

Here is my current code…

RewriteEngine on
RewriteRule .*/admin(.+) admin$1 [QSA]
RewriteRule .*/blog(.+) blog$1 [QSA]
RewriteCond %{REQUEST_URI} !.*(admin/|blog/)
RewriteRule !\.(css|js)$ index.php

I can remove the blog/ condition on the second to last line however the blog module ends up rewriting to index.php. I’ve done some tweaking for the past few hours without any success and unfortunately multi-domain support is a non-existent issue online as far as I can tell.

I know this is a tricky setup and I’ll try to clarify any questions anyone has.

  • 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-28T01:28:51+00:00Added an answer on May 28, 2026 at 1:28 am

    As far as I understand, instead of the too generic .* match at the start of your RewriteRules you should try to match the multi-domain strings.

    So let’s try something like that:

    RewriteRule ^[^/]*/admin(.+) admin$1 [QSA]
    RewriteRule ^[^/]*/blog(.+) blog$1 [QSA]
    

    Where [^/] means anything which is not “/“, and ^[^/]*/foo means start with anything that is not a slash several times until you reach slash and then foo. So this should be an efficient way to detect ‘foo’ as being only a first level directory name, as ‘/‘ is not allowed in a domain name.

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

Sidebar

Related Questions

I need to prevent a document from being saved / saved as (say from
I need to prevent user from selecting text (select all or select a portion
I need to capture keystokes from a wedge device and prevent any controls or
I need to prevent Session Fixation , a particular type of session hijacking, in
I need to prevent my double to print in scientific notation in my file,
I'm writing an XML schema and need to prevent the text of an element
I'm working on a couple of Linux tools and need to prevent installation on
I'm going to running thousands of queries into SQL and I need to prevent
Does cygwin allow a statically compiled binary? This would prevent the need for cygwin1.dll
I need to check all of my asp code to prevent SQL injection. Should

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.