htaccess 重写规则无需更改 URL

htaccess rewriterule whitout changing URL

我有一个问题,希望你能帮我解决这个问题。

-我有多个域正在寻找同一个 IP。 -我在 htaccess 中做了重写规则,但他们将 URL 更改为 :
网站1.nl/website1/index.php -root 看起来像

    -web
       -website1
          -index.php
       -website2
           -index.php

-如果我将 index.php 放在根目录 (map :web) 中,我会得到一个干净的 URL 只有 "website1.com" 而没有 index.php

这是我的问题: 我怎样才能改变这是 htaccess whitout 改变 URL?

到目前为止我得到的但没有工作的是:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?website1\.com$ [NC]
RewriteRule ^(.*)$ website1/ [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?website2\.com$ [NC]
RewriteRule ^(.*)$ website2/ [R=301,L]

我希望有人能帮助我??????

您可以在 root .htaccess 中使用这两条规则:

RewriteEngine On
RewriteBase /

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

RewriteCond %{HTTP_HOST} ^(www\.)?website2\.com$ [NC]
RewriteRule ^((?!website1/).*)$ website2/ [NC,L]