服务器 Gind.cn

服务器问题集锦,包括 Linux(Ubuntu, Centos,Debian等)和Windows Server服务器

Apache2 mod_rewrite干净的URL – 工作,但文件不可访问

服务器:Debian Jessie Apache:2.4.9-1 PHP:5.5 我想要的是所有非文件和非目录redirect到我自己处理它们的index.php。 由于我的项目的性质,我必须从一个虚拟主机内部工作。 我正在使用虚拟主机(vHosts)和mod_rewrite在我正在工作的Web项目。 这是vHost文件… <VirtualHost *:80> ServerName foo.com ServerAlias www.foo.com ServerAdmin [email protected] DocumentRoot /srv/foo/main/www/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php [L] </IfModule> </VirtualHost> vHost按预期工作,重写规则将请求redirect到index.php。 但是当我尝试访问服务器上的文件时,例如: foo.com/css/style.css 位于: /srv/foo/main/www/css/style.css 我的请求被redirect到index.php 这很奇怪,因为重写条件语句应该解决这个问题。 所有文件夹权限都设置为755,所有文件都设为644。 我已经能够毫无疑问地确认重写条件是不匹配的。 我可以通过查看Apache的错误日志,并为mod_rewrite启用debugging输出来看到这一点。 为什么两个RewriteCond语句不正确匹配? 他们可能没有看到vHost DocumentRoot? 更新:closures重写引擎允许我到我正在testing的文件。 IE,我的URI是正确的。 我知道我的路是好的,条件只是因为某种原因失败了。