我在 Vagrant 中有虚拟环境ubuntu/trusty64
。使用了 phalcon 框架。已经安装
> apache2 -v
Server version: Apache/2.4.7 (Ubuntu)
Server built: Jan 14 2016 17:45:23
/etc/apache2/sites-avaliable/mysite.conf
<VirtualHost 192.168.33.10:80>
ServerAdmin webmaster@localhost
DocumentRoot /vagrant/
ServerName site.loc
ServerAlias www.site.loc
<Directory /vagrant/>
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
EnableMMAP Off
EnableSendFile off
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
html 文件 /public/index.php
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="/src/css/test.css" type="text/css">
</head>
<body>
</body>
</html>
css 文件 /src/css/test.css
body {
background: red;
}
.htaccess /.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
答案1
我通过将 src 文件夹与 index.php 放在同一目录中解决了这个问题