用于从url中删除部分目录的Apache重写规则

用于从url中删除部分目录的Apache重写规则,apache,.htaccess,url-rewriting,apache2,Apache,.htaccess,Url Rewriting,Apache2,我使用apache设置了以下测试站点,并在以下位置提供服务/htdocs/www/*: https://local.sweetcar.com/www/mycompany/ https://local.sweetcar.com/www/sweetcar/ 我想配置一个apache重写来服务以下URL https://local.mycompany.com/ https://local.sweetcar.com/ 因此,www/mycompany/和www/sweetcar/从url中删除,而其

我使用apache设置了以下测试站点,并在以下位置提供服务
/htdocs/www/*

https://local.sweetcar.com/www/mycompany/
https://local.sweetcar.com/www/sweetcar/
我想配置一个apache重写来服务以下URL

https://local.mycompany.com/
https://local.sweetcar.com/
因此,www/mycompany/www/sweetcar/从url中删除,而其他所有内容都保留下来

这是我尝试过的,但没有成功:

.htaccess

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

您可以在site root.htaccess中使用以下规则:

RewriteEngine On
RewriteBase /

RewriteCond %{ENV:REDIRECT_STATUS} !200
RewriteCond %{HTTP_HOST} ^local\.([^.]+)\. [NC]
RewriteRule !^www/ www/%1%{REQUEST_URI} [L,NC]

RewriteRule ^index\.php$ - [L]

local.mycompany.com
是否有类似于
local.sweetcar.com
VirtualHost
条目?是的,两个网站都使用上述URL工作感谢回复。我把.htaccess放在
/htdocs
中,得到了一个500错误,有什么想法吗?你能检查一下你的Apache error.log,看看是什么原因导致
请求由于可能的配置错误超过了10个内部重定向的限制。如有必要,使用“LimitInternalRecursion”增加限制。使用“LogLevel debug”获取回溯。
获取相同的500错误和apache日志错误。让我们来看看。