我需要重写目录中的所有文件,基本上使PHP自己的一些推广CSS代替。我想要做的与该特定目录中的.htaccess文件。
I need to rewrite all the files in a directory and essentially make their extentions css instead of php. I want to do with with a .htaccess file within that specific directory.
什么是这样做的正确的方法以及是否有我需要设置确保文件被读作.css文件的任何特殊的PHP头文件是否正确?
What is the correct method of doing so and are there any special PHP headers I need to set the ensure the file is read as a .css file correctly?
推荐答案
我觉得你更想被internaly改写为 *。CSS
的请求 *。PHP
。因此,尝试这样的:
I think that you rather want requests of *.css
to be rewritten internaly to *.php
. So try this:
RewriteEngine on
RewriteRule ^(foo/.*).css$ $1.php [L]
在富
是这里的特定目录中。
While foo
is here the specific directory.
您现在应该明确声明为文本/ CSS输出
使用下面的PHP脚本的开始:
You now should explicitly declare the output as text/css
using the following at the begin of the PHP script:
<?php
header('Content-Type: text/css;charset=<your charset>');
替换&lt;您的字符集&GT;
用任何字符集/编码您使用的是(或许 ISO-8859-1
或 UTF-8
)。
Replace <your charset>
by whatever charset/encoding you are using (probably ISO-8859-1
or UTF-8
).
相关推荐
最新文章