htaccess 文件中的 AddHandler 和 AddType 有什么区别
有人可以解释 htaccess 文件中 AddType 和 AddHandler 之间的区别吗?我想要进行设置,以便我可以让 javascript 文件 (.js) 通过服务器运行,就像它是 php 文件 (application/x-httpd-php5) 一样,然后将其作为 (text /javascript) 文件。我该如何配置这个?
Can someone explain what the difference is between AddType and AddHandler in htaccess files? I want to make the settings such that I can have a javascript file (.js) be run through the server as though it were a php file (application/x-httpd-php5) but then sent to the user's browser as a (text/javascript) file. How might i configure this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AddHandler http://httpd.apache.org/docs/2.0/mod/ mod_mime.html#addhandler 告诉服务器如何处理文件类型。 AddType http://httpd.apache.org/docs/2.0/mod/ mod_mime.html#addtype 告诉服务器要为客户端提供什么 MIME 类型。
AddHandler http://httpd.apache.org/docs/2.0/mod/mod_mime.html#addhandler tells the server how to handle the file type. AddType http://httpd.apache.org/docs/2.0/mod/mod_mime.html#addtype tells the server what MIME type to give the client.
将所有 .js 文件解析为 php 听起来并不是一个好主意。我建议使用 .htaccess Rewrite 指令将有问题的 .js 文件映射到您的 php 脚本。
然后添加
到您的 php 输出。
I doesn't sound like a great idea to parse all .js files as php. I would suggest using a .htaccess Rewrite directive to map the .js files in question, to your php script.
Then add
to your php output.