我怎样才能得到DirectoryIndex的文件名给定的URI使用PHP? [英] How can I get the DirectoryIndex filename for a given URI using PHP?

查看:137
本文介绍了我怎样才能得到DirectoryIndex的文件名给定的URI使用PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有了用户复制URI到文本字段的PHP程序。然后,它需要的文本字段,并解析出文件名。我遇到的问题是,如果用户只是把http://www.test.com/directory/我怎么能知道是否被送达的文件的index.php,index.html的,等等等等?我试着用函数apache_lookup_uri,但它不是给我的文件名。

I have a PHP program that has the user copying a URI into a text field. It then takes that text field and parses out the filename. The problem I'm having is if the user just puts "http://www.test.com/directory/" how can I tell if the file being served is index.php, index.html, etc etc? I tried using apache_lookup_uri, but it's not giving me the filename.

感谢

推荐答案

您不能。

如果将服务器配置不同,你可以有文件设置为如 main.html中 jacko.asp 目录索引 iphone4.jsp

If the server is configured differently you can have files setup for directory index like main.html jacko.asp iphone4.jsp

永邦你只对你到底看到什么parse_url给你。

Franky you only see on your end what parse_url gives you

<?php
$url = 'http://username:password@hostname/path?arg=value#anchor';

print_r(parse_url($url));

echo parse_url($url, PHP_URL_PATH);
?>

在上面的例子将输出:

The above example will output:

Array
(
   [scheme] => http
   [host] => hostname
   [user] => username
   [pass] => password
   [path] => /path
   [query] => arg=value
   [fragment] => anchor
)

/路径

这篇关于我怎样才能得到DirectoryIndex的文件名给定的URI使用PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆