我正在尝试使用Apache 2创build自动子域(在Ubuntu上运行)
我已经使用VirtualDocumentRoot指令来执行文档根目录的初始声明,在我的虚拟主机文件中包含以下内容:
<VirtualHost *:80> VirtualDocumentRoot /var/www/dev/branches/%1/public/ ServerAlias *.dev.example.com <Directory /> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
这对于第一部分来说很好,所以对foo.dev.example.com的请求具有/var/www/dev/branches/foo/public的文档根目录,这很好。
唉,公共文件夹中的*.htaccess文件似乎没有工作。
所有请求都应该通过公用文件夹中的index.php发送,如.htaccess文件所示:
Options -Indexes <IfModule mod_rewrite.c> RewriteEngine on # redirects requests to index.php where no file or directory exists RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php </IfModule>
对foo.dev.example.com的请求有效,但对foo.dev.example.com/subdir的请求失败。
帮帮我!
我有一个错误日志,显示这是一个mod_rewrite问题:
[Thu Aug 04 14:05:45 2011] [error] [client 217.206.134.99] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. [Thu Aug 04 14:05:45 2011] [debug] core.c(3063): [client 217.206.134.99] r->uri = /var/www/dev/branches/amy/public/index.php [Thu Aug 04 14:05:45 2011] [debug] core.c(3069): [client 217.206.134.99] redirected from r->uri = /var/www/dev/branches/amy/public/index.php [Thu Aug 04 14:05:45 2011] [debug] core.c(3069): [client 217.206.134.99] redirected from r->uri = /var/www/dev/branches/amy/public/index.php [Thu Aug 04 14:05:45 2011] [debug] core.c(3069): [client 217.206.134.99] redirected from r->uri = /var/www/dev/branches/amy/public/index.php [Thu Aug 04 14:05:45 2011] [debug] core.c(3069): [client 217.206.134.99] redirected from r->uri = /var/www/dev/branches/amy/public/index.php [Thu Aug 04 14:05:45 2011] [debug] core.c(3069): [client 217.206.134.99] redirected from r->uri = /var/www/dev/branches/amy/public/index.php [Thu Aug 04 14:05:45 2011] [debug] core.c(3069): [client 217.206.134.99] redirected from r->uri = /var/www/dev/branches/amy/public/index.php [Thu Aug 04 14:05:45 2011] [debug] core.c(3069): [client 217.206.134.99] redirected from r->uri = /var/www/dev/branches/amy/public/index.php [Thu Aug 04 14:05:45 2011] [debug] core.c(3069): [client 217.206.134.99] redirected from r->uri = /var/www/dev/branches/amy/public/index.php [Thu Aug 04 14:05:45 2011] [debug] core.c(3069): [client 217.206.134.99] redirected from r->uri = /var/www/dev/branches/amy/public/index.php [Thu Aug 04 14:05:45 2011] [debug] core.c(3069): [client 217.206.134.99] redirected from r->uri = /user/login [Thu Aug 04 14:05:45 2011] [debug] mod_deflate.c(615): [client 217.206.134.99] Zlib: Compressed 630 to 389 : URL /var/www/dev/branches/amy/public/index.php
你可以使用这些规则或多或less地工作:
Options -Indexes <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [L] </IfModule>
唯一的问题是,如果在其中一个目录中有一个默认的索引页面,它只能被直接访问, http://domain.tld/subdir/index.php只需使用http://domain.tld/ subdir /会把它重写到http://domain.tld/index.php