Getting rid of files from domain name using PHP

拥有回忆 提交于 2019-12-31 05:33:26

问题


I have the following URLs:

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

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/

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


回答1:


ok I found the answer :

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

so the url will look like this :

http://website.com/folder1/


来源:https://stackoverflow.com/questions/31493950/getting-rid-of-files-from-domain-name-using-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!