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 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝