我有一个问题,包括PHP代码在我的聚合物项目。我试图在我的服务器上设置一个".htaccess“文件,但是它没有工作。此外,我认为没有一种简单的方法可以将"index.html“文件更改为"index.php”文件,因为它是在许多其他文件中引用该文件的,我不知道。我在本地计算机上使用一个gulp服务器,我试图在那里包含一个PHP支持,但是失败了。这是gulpfile的代码(只对原始文件进行了最小的修改):
var gulp = require('gulp');
var connect = require('gulp-connect-php');
...
// Watch Files For Changes & Reload
gulp.task('serve', ['elements', 'images'], function () {
connect.server({}, function (){
browserSync({
notify: false,
snippetOptions: {
rule: {
match: '<span id="browser-sync-binding"></span>',
fn: function (snippet) {
return snippet;
}
}
},
// Run as an https by uncommenting 'https: true'
// Note: this uses an unsigned certificate which on first access
// will present a certificate warning in the browser.
// https: true,
server: {
baseDir: ['.tmp', 'app'],
routes: {
'/bower_components': 'bower_components'
}
}
});
});
gulp.watch(['app/**/*.html'], reload);
gulp.watch(['app/styles/**/*.css'], ['styles', reload]);
gulp.watch(['app/elements/**/*.css'], ['elements', reload]);
gulp.watch(['app/{scripts,elements}/**/*.js'], ['jshint']);
gulp.watch(['app/images/**/*'], reload);
});
...发布于 2015-06-23 19:16:40
在您的.htaccess文件中,类似这样的内容应该会迫使服务器将所有列出的文件类型(扩展名)处理为PHP:
AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .html
DefaultType application/x-httpd-php5注意最后一个是".html“。但是,正如我在评论中所指出的,您不是引用PHP,而是引用JavaScript,我会冒险猜测您可能有点过头了。
祝好运。:-)
https://stackoverflow.com/questions/31010913
复制相似问题