最近学PHP,到第三章的时候卡住了。我引用了一个HTML模板,但是这个模板无法引用css文件,下图是这个HTML模板:
<?php echo $page_title; ?>Your Website
catchy slogan...
但是,我通过在位于表头中的
<?php include ('./includes/style.css'); ?>
它又工作了。通过审查源代码发现所有CSS代码都集中到这个HTML文件来了。我知道这样不好,但有没有办法解决?
还有,我在网站根目录里放入 *.html 文件提示 File not found.(能解析*.php)。
Nginx配置文件:
server {
listen 80 default_server;
root /var/www/html;
index index.html index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/error.log error;
sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}
}
=====================UPDATE on 2016.02.16 00:56===================
这是修改后的代码:
<?php echo $page_title; ?><?php include ('./includes/style.css'); ?>
对,它能工作:
我的项目文件结构: