我真的很喜欢我的index.html才能够对它有一个PHP脚本的工作。我看,你可以通过htaccess文件做到这一点。我只能访问一个子网站的目录,在那里我可以通过FTP上传我的文件。
I would really like my index.html to be able to have a PHP script work on it. I read that you can do this through the htaccess file. I only have access to a subdomain website directory, where I can upload my files through FTP.
目录不具有一个htaccess文件,所以我创建了一个使用记事本:htaccess的,并已将此添加到文件:
The directory did not have a htaccess file, so I created one using notepad: .htaccess and added this to the file:
AddType application/x-httpd-php .html
现在的问题是,而不是装载index.html页面,它下载它作为一个文件...我需要一些额外添加到htaccess文件? :•
The problem is, instead of loading the index.html page, it downloads it as a file...would I need to add something extra to the htaccess file? :S
推荐答案您不必将文件命名为 index.html的有它服务在默认情况下。您可以使用同一个条目修改默认文档的的.htaccess 文件是这样的:
You don't need to name the file index.html to have it served by default. You can change the default document using your with an entry in your .htaccess file like this:
DirectoryIndex index.php
然后,当你浏览到 yoursubdomain.example 您奉上的index.php 而不是 index.html的。
如果真的想为PHP除preT你的.html文件,那么你在你的问题时,PHP运行作为Apache模块将工作过的条目。如果你的主机正在运行PHP作为CGI,你想要的:
If really do want PHP to interpret your .html documents then the entry you had in your question will work when PHP is running as an Apache module. If your host is running PHP as CGI, you want:
AddHandler application/x-httpd-php .html如果它仍然无法正常工作,那么这个网页有一些建议:
If it still doesn't work, then this web page has some more suggestions:
- 的www.velvetblues/web-development-blog/how-to-parse-html-files-as-php/
更多推荐
htaccess的下载文件,而不是装
发布评论