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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:02:49+00:00 2026-06-11T20:02:49+00:00

I have an strange situation with .htaccess configuration. I have a multidomain hosting, with

  • 0

I have an strange situation with .htaccess configuration.
I have a multidomain hosting, with one directory per each domain.
For example, I have:

http://www.domain1.com
http://www.domain2.com

and the following directory structure:

/domain1/
/domain1/index.php
/domain2/
/domain2/index.php
/domain2/subdirectory/
/domain2/subdirectory/index.php

and a .htaccess file with the following content:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/domain1/.*$
RewriteRule ^(.*)$ domain1/$1 [L]

RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/domain2/.*$
RewriteRule ^(.*)$ domain2/$1 [L]

all works as I like with one exception:
if I do:

http://www.domain2.com/subdirectory/

(with a slash at the end)
the content is showed propertly and the url on the address bar keep unchanged, but
if I do:

http://www.domain2.com/subdirectory

(without a slash at the end)
the content is showed properly but the url on the address bar is changed to:

http://www.domain2.com/domain2/subdirectory/

(notice the subdirectory name and a slash is appended at the end)
and I don’t like the user see that change on the address bar, that’s my problem

  • 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-06-11T20:02:50+00:00Added an answer on June 11, 2026 at 8:02 pm

    This is mod_dir and DirectorySlash interferring with the URI-file mapping pipeline. By default DirectorySlash is turned on, which makes it so when apache thinks a request is for a directory, and it’s missing the trailing slash, then it 301 redirects to the URI with the trailing slash. There’s a good reason for doing this because of a possible information disclosure security concern. If you don’t allow for directory indexing, you could just turn it off:

    DirectorySlash Off
    

    And then Apache won’t redirect to the trailing slash at all. Or you can do the redirecting yourself as part of the rewrite engine. The reason why your internally rewritten URL is exposed is because 2 modules are mangling the URI, mod_dir and mod_rewrite, and they’re doing it without any awareness of each other. So the URI gets rewritten by mod_rewrite and then mod_dir comes along and says “this is a directory!”, mangles the URI some more by adding a trailing slash and flags it for a redirect response. Eventually, what you get is a redirect with a mangled URI. By handling the redirect from within mod_rewrite, by the time it gets to mod_dir, everything’s peachy.

    These would need to be above your current rules

    RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/domain1/.*$
    RewriteCond %{DOCUMENT_ROOT}/domain1%{REQUEST_URI} -d
    RewriteRule ^(.*[^/])$ /$1/ [L,R=301]
    
    RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/domain2/.*$
    RewriteCond %{DOCUMENT_ROOT}/domain2%{REQUEST_URI} -d
    RewriteRule ^(.*[^/])$ /$1/ [L,R=301]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange situation in one view controller where this line crashes in
Strange situation. inside a solution I have several projects. One of them is called
I have a strange situation with my web service. It is a simple one
I have a strange situation in regards to xml serialization... If I run MyApp.exe
I have a strange situation here. In my android app, I have a layout
I have a very strange situation. I have a large set of records to
I have a very strange situation. I´m working on a pretty big Java application
I have the next very strange situation and problem: .NET 4.0 application for diagram
Strange situation. If I have these tables: CREATE TABLE t1 (id INT, title VARCHAR(20),
I have a strange situation where I can build a project with ant without

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.