.htaccess 域的内部重写不';不适用于子目录

.htaccess 域的内部重写不';不适用于子目录,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,比如说,我有一个域名 test.example.com .HTACCESS文件位于var/www/html/,因此test.example.com也指向该位置 我想test.example.com在内部加载/var/www/html/example/test 使用以下代码 RewriteEngine on RewriteCond %{HTTP_HOST} ^test\.example\.com$ [NC] RewriteRule ^$ example/test%{REQUEST_URI} [

比如说,我有一个域名

test.example.com
.HTACCESS
文件位于
var/www/html/
,因此
test.example.com
也指向该位置

我想
test.example.com
在内部加载
/var/www/html/example/test

使用以下代码

RewriteEngine on

RewriteCond %{HTTP_HOST} ^test\.example\.com$ [NC]
RewriteRule ^$ example/test%{REQUEST_URI} [NC,QSA,L]

重写对root用户有效,但当我加载
test.example.com/foo
时,它会在内部和外部分别指向
/var/www/html/example/test/foo
test.example.com/foo
时显示404

RewriteRule ^(.*)$ example/test%{REQUEST_URI} [L]

问题是**^$**只匹配根目录,而在请求/foobar时不匹配。我已将模式更改为^(.*)$以允许所有URI。

这将从外部将我重定向到
http://test.example.com/example/test/foo
。我不想更改浏览器中的url。不,这不会从外部重定向。您可能有其他规则执行此操作。这是我的整个.htaccess。这是一个全新的apache安装。