Tips for debugging .htaccess rewrite rules

后端 未结 16 3105
萌比男神i
萌比男神i 2020-11-21 05:17

Many posters have problems debugging their RewriteRule and RewriteCond statements within their .htaccess files. Most of these are using a shar

16条回答
  •  礼貌的吻别
    2020-11-21 05:35

    If you're planning on writing more than just one line of rules in .htacesss,
    don't even think about trying one of those hot-fix methods to debug it.

    I have wasted days setting multiple rules, without feedback from LOGs, only to finally give up.
    I got Apache on my PC, copied the whole site to its HDD, and got the whole rule-set sorted out, using the logs, real fast.
    Then I reviewed my old rules, which been working. I saw they were not really doing what was desired. A time bomb, given a slightly different address.

    There are so many pit falls in rewrite rules, it's not a straight logic thing at all.
    You can get Apache up and running in ten minutes, it's 10MB, good license, *NIX/WIN/MAC ready, even without install.
    Also, check the header lines of your server and get the same version of Apache from their archive if it's old. My OP is still on 2.0; many things are not supported.

提交回复
热议问题