在我的服务器上我有多个域。mod_rewrite不隐藏子目录
RewriteEngine On
RewriteBase/
# 1. Redirect multiple domains to http://domain.de/
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.de [NC]
RewriteRule ^/?(.*) http://domain.de/$1 [L,R,NE]
# 2. Redirect all requests to /subdirectory
RewriteRule ^$ /subdirectory [L]
的2.规则工作正常,但它并不隐藏子目录中的网址,也没有按预期工作:为http://domain.de/content/image.png
返回404的请求,因为实际的文件位于http://domain.de/subdirectory/content/image.png
此外,我有一些工具位于子目录/subdirectory
旁边的工具文件夹。我想确保我仍然可以访问它们。这目前正在工作。
问题
我怎样才能确保,对于http://domain.de/content/image.png
作品的要求?
我试过
RewriteCond %{REQUEST_URI} !^/subdirectory/
RewriteRule (.*) /subdirectory/$1 [L]
但是,这只是返回错误500在Apache的错误日志中的条目:`请求超过了10个内部重定向的上限,由于可能的配置错误。
编辑
由拉维Thapliyal提供的指导后,有(我猜)一件事剩余:删除URL中的子目录。
[[email protected] html]$ curl -I domain.de/
HTTP/1.1 301 Moved Permanently
Date: Mon, 21 Oct 2013 12:42:22 GMT
Server: Apache/2.2.22 (Ubuntu)
Location: http://domain.de/subdirectory/index.php
Vary: Accept-Encoding
Content-Type: text/html
这是获取返回什么,但其实我是想获得HTML不是一个位置,然后头当然会被重定向我内外兼修的子目录,然后将其对用户可见。可能与某个子目录中的另一个.htaccess文件有关?
EDIT2
看来问题是关系到subdirectory
背后的TYPO3安装。接受的答案按预期工作。
访问域时将导致403。德。错误日志说:'由Options指令禁止的目录索引:/ var/www /' –
为'^/$'添加一个'RewriteCond'。 –
这留下了剩余的一件事:URL中的可见子目录。 –