简体   繁体   中英

.htaccess DirectoryIndex /subfolder/index.php seems to manage links in a funny way

  • I have the default myIndex.php in a subfolder of public_html.

  • I added a file .htaccess in public_html.

  • I added DirectoryIndex /subfolder/myIndex.php in it.

myIndex.php contains links and includes. Includes seems to work but links dont: no images and no css but menu.php is included. Links in menu.php dont work either.

If I

  • change .htaccess to DirectoryIndex index.php,

  • create a file index.php in public_html,

  • and put a link to "./subfolder/myIndex.php" in it

    everything works fine.

I dont understand what happens here.

DirectoryIndex determines what to do, when a client requests a directory. If you have

DirectoryIndex /subfolder/myIndex.php

then exactly this script will be executed every time the client requests a directory, no matter where this directory is, eg /anotherfolder/ or /static/ . But when you have

DirectoryIndex index.php

instead, Apache looks for an index.php in the requested directory, eg /anotherfolder/index.php or /static/index.php .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM