dongran1779 2014-01-14 07:08
浏览 16
已采纳

文件和目录命名为相同的PHP

I currently have these two pieces to my website.

localhost/FTS/papers - which is a php file
localhost/FTS/papers/ - which is a directory

What I am wanting to do is make it so that when I load:

localhost/FTS/papers -or-
localhost/FTS/papers/ -or-
localhost/FTS/papers.php

I want them all to go to the papers file.

Right now it is accessing the directory instead of the file which is not what I want.

  • 写回答

3条回答 默认 最新

  • dporb84480 2014-01-14 07:37
    关注

    Place this rule in your DOCUMENT_ROOT/.htaccess file:

    RewriteEngine On
    RewriteBase /FTS/
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{DOCUMENT_ROOT}/FTS/$1.php -f
    RewriteRule ^(.+?)/?$ $1.php [L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?