How to block multiple mod_rewrite passes (or infinite loops) in a .htaccess context

后端 未结 3 1745
清酒与你
清酒与你 2020-12-08 11:14

I\'m working on a website running on a shared Apache v2.2 server, so all configuration is via .htaccess files, and I wanted to use mod_rewrite to map URLs to the filesystem

3条回答
  •  没有蜡笔的小新
    2020-12-08 12:03

    I'm not too sure why you need to do that, but I'd suggest a couple of things for users who run in such a situation:

    1. How about renaming the folder Bob into Alice and vice versa? Then Apache doesn't need to do anything about them.

    2. If that's important for your application, could you just transform the app. to detect Bob and Alice and just swap those in your app. instead?

    In PHP it would be something like this:

    if($path == "Bob") {
      $path = "Alice";
    }
    else if($path == "Alice") {
      $path = "Bob";
    }
    

    Done.

    Otherwise adding another sub-folder could be useful. So /Bob becomes /a/Alice and /Alice becomes /b/Bob. Then you remove the confusion. That could also be done with another parameter (query string), which is more or less what you're doing by setting an environment variable that you test in your .htaccess.

提交回复
热议问题