search

Home  >  Q&A  >  body text

macos - Apache column file pointing error under OS X

I recently changed to a Mac, and something strange happened when I paired it with Apache.

For example, my local directory is ~/Work/app/a/b, and I point www.test.com to the local ~/Work directory, then visit http://www.test.com/app/ a/b is no problem.

But when I open Options Indexes and open http://www.test.com/app/a/, I can see the b directory listed. Then I click on it and the URL jumps. Go to http://www.test.com/app/b! Note that it is normal to open directly with an absolute path and will not jump (so I don't think it is a permissions issue).

I looked at .htaccess in the root directory and didn’t see any clues. Commenting out mod_rewrite has no effect.

The strange thing is that there are many directories under my app, but not every one of them will have the problem. I tried to find the commonality among them, and it seems that there is only one thing: the directories (files) that bounce back are all at the last level of the directory.

I wonder if you have ever encountered this situation. My Apache version is 2.4.10 that comes with Yosemite.

Thanks!

淡淡烟草味淡淡烟草味2750 days ago620

reply all(1)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-16 17:04:20

    Ask and answer your own questions...

    The reason is simple, because I did not turn on mod_dir
    mod_dir 中有一个参数叫 DirectorySlash, which is used to automatically add a slash after the directory address.
    I have not loaded this module before, so naturally this function does not work.
    And the reason why I think it's good and bad is that sometimes I put a slash myself.

    The reason for turning off mod_dir,是为了让 DirectoryIndex is that this parameter is invalid. This can prevent Apache from automatically opening index.html (for local development) in the directory. As a result, I dug a hole for myself.
    In fact, you only need to set DirectoryIndex disabled (only available in version 2.4 or above).

    Reference documentation

    reply
    0
  • Cancelreply