How to name file and directory the same with .htaccess rewrite rules?

后端 未结 2 880
感动是毒
感动是毒 2021-01-27 13:16

I am trying to work on my \"pretty-urls\" and I\'ll be the first to admit I really don\'t know what I\'m doing. I\'m trying to wrap my head around it though. So what I am trying

2条回答
  •  星月不相逢
    2021-01-27 13:55

    This is because of mod-dir Apache directory module that runs before mod-rewrite . When you request an existent directory without a traling slash the mod-dir issues a permanent 301 Redirect from /dir to /dir/ and that is why you are unable to rewrite the uri.

    To fix this, you need to tell mod-dir not to perform the redirection when a directory without a traling slash is requested. You can use DirectorySlash directive in your htaccess to change this behaviour.

    Add the following line to your htaccess :

    DirectorySlash off
    

    Reference : https://httpd.apache.org/docs/2.4/mod/mod_dir.html

提交回复
热议问题