使用 PHP 从域名中删除文件 [英] Getting rid of files from domain name using PHP

查看:50
本文介绍了使用 PHP 从域名中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下网址:

http://website.com/folder1/file.php
http://website.com/folder2/file.html

我想知道 PHP 中是否有任何方法可以让我隐藏文件及其扩展名,使 URL 看起来像这样:

I want to know if there is any way in PHP that will let me hide the files and their extensions so the URLs will look like this:

http://website.com/folder1/
http://website.com/folder2/

我知道使用 htaccess 和 mod_rewrite 可以做到这一点,但我只想使用 PHP.

I know this is possible using htaccess and mod_rewrite but I want to do it using PHP only.

推荐答案

ok 我找到了答案:

<? echo dirname("http://website.com/folder1/file.php"); ?>

所以网址看起来像这样:

so the url will look like this :

http://website.com/folder1/

这篇关于使用 PHP 从域名中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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