简体   繁体   English

使用.do扩展名为.php扩展名为所有php文件

[英]Using .do extension as .php extension for all php files

How can I hide the normal PHP filename extensions and use my own extensions? 如何隐藏正常的PHP文件扩展名并使用我自己的扩展?

For example, using example.do instead of example.php . 例如,使用example.do而不是example.php

I want files with the the .do filename extension to be treated as PHP files, so that I can access example.do . 我希望将带有.do文件扩展名的文件视为PHP文件,以便我可以访问example.do How can I do this? 我怎样才能做到这一点?

Add the following line to your .htaccess file .htaccess下行添加到.htaccess文件中

AddHandler application/x-httpd-php .do

This tells the server to process all files ending with .do as .php . 这告诉服务器处理以.do结尾的所有文件为.php

Another alternative is sethandler . 另一种选择是sethandler

According to the Apache documentation , the difference is: 根据Apache文档 ,区别在于:

If you would prefer only the last dot-separated part of the filename to be mapped to a particular piece of meta-data, then do not use the Add* directives. 如果您希望仅将文件名的最后一个点分隔部分映射到特定的元数据,则不要使用Add *指令。 For example, if you wish to have the file foo.html.cgi processed as a CGI script, but not the file bar.cgi.html, then instead of using AddHandler cgi-script .cgi, use 例如,如果您希望将文件foo.html.cgi作为CGI脚本处理,而不是文件bar.cgi.html处理,那么请使用AddHandler cgi-script .cgi,而不是使用
<FilesMatch "[^.]+\.cgi$">
  SetHandler cgi-script
</FilesMatch></blockquote>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM