dongpai1942 2013-04-20 01:10
浏览 22
已采纳

为什么有些网站在文件扩展名末尾没有显示.php? [重复]

This question already has an answer here:

Sometimes when I look at a websites URL it will say something like this

www.website.com/index.php

and other times it will look like this

www.website.com/index/

Why does the second URL not have a .php or .html extension?

</div>
  • 写回答

1条回答 默认 最新

  • dragonhong641016 2013-04-20 01:33
    关注

    In a normally configured web server,

    www.website.com/index.php
    

    tells it to load the index.php file from the webroot directory. This

    www.website.com/index/
    

    tells it to look in the /index/ directory for a file matching what is listed in the DirectoryIndex configuration directive in the server's httpd.conf file or in an .htaccess file in the web site's webroot directory (see http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex for details).

    A sample configuration directive would look like this:

    DirectoryIndex index.php index.html default.html default.htm
    

    This would tell the web server to, when no filename is given, to look in the current directory for an index.php file, if not found look for an index.html file, and if not found a default.html file and so on for everything else on the line.

    If you want to be able to run PHP files without having to have .php on the end of them, you would set a default handler in your configuration files (httpd.conf or .htaccess) such as:

    ForceType application/x-httpd-php 
    

    This will tell Apache to handle all files as PHP whether they have a .php extension or not. (See http://httpd.apache.org/docs/2.2/mod/core.html#forcetype )

    You can also use ModRewrite to remap the URLs if you prefer, but ModRewrite directives can be confusing and difficult to troubleshoot.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog