您好,我一直在努力在 htaccess 上执行以下操作,但它似乎不起作用。
有人能帮帮我吗?
AddType 应用程序/x-httpd-php .js
我尝试了 php4、php5 版本所有我能在谷歌上找到的东西,但我没有运气。
我错过了什么?
在我的 file.js 中
是以下...
<?php
$(document).ready();//jquery/javascript
?>
我预计会出现 php fatal error ,但我看到上面的内容完全是纯文本。
最佳答案
如果您只想使用 .htaccess 配置来做到这一点(谁想在每个 PHP 文件中设置 header ?):
<FilesMatch "\.css$">
SetHandler application/x-httpd-php
Header set Content-type "text/css"
</FilesMatch>
<FilesMatch "\.js$">
SetHandler application/x-httpd-php
Header set Content-type "application/javascript"
</FilesMatch>
关于php - 使用 htaccess 将 js/css 解析为 PHP 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10722375/