apache 调试 .htaccess 的流行技术
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/669189/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Popular techniques to debug .htaccess
提问by John
I'm a self-taught coder and I like to debug by echoing suspicious variables and commenting out code.
我是一名自学成才的编码员,我喜欢通过回显可疑变量和注释掉代码来进行调试。
Lately, I've had to learn more about the .htaccess file. I need it to do things like interpret php scripts as php5, url rewriting, limit file upload size etc.... I have a lot of trouble debugging a .htaccess file. I often have to migrate PHP applications from one shared hosting environment to another. Sometimes this breaks the .htaccess file (or instead, something in the .htaccess file breaks the site). I check to make sure domain names are updated.
最近,我不得不更多地了解 .htaccess 文件。我需要它来做一些事情,比如将 php 脚本解释为 php5、url 重写、限制文件上传大小等......我在调试 .htaccess 文件时遇到了很多麻烦。我经常需要将 PHP 应用程序从一个共享托管环境迁移到另一个共享托管环境。有时这会破坏 .htaccess 文件(或者相反,.htaccess 文件中的某些内容会破坏站点)。我检查以确保域名已更新。
Are there popular techniques for debugging a .htaccess file? Is it just look in the apache logs? Anything else?
是否有用于调试 .htaccess 文件的流行技术?它只是查看apache日志吗?还要别的吗?
采纳答案by Alekc
Looking in the apache logs is the easiest way to debug .htaccess imho (adding rewriteLog Directive if necessary)
查看 apache 日志是调试 .htaccess imho 的最简单方法(如有必要,添加 rewriteLog 指令)
About migrating: if you are not using any physical file paths inside .htaccess (i.e. /var/www/site/script.php) they should be working without problems. If this is not the case, first try to remove all options and leave only redirect directives, in this mode you can see if it's problem with server configuration which denies rewriting of default settings.
关于迁移:如果您没有在 .htaccess 中使用任何物理文件路径(即 /var/www/site/script.php),它们应该可以正常工作。如果不是这种情况,首先尝试删除所有选项并只保留重定向指令,在这种模式下,您可以查看服务器配置是否存在拒绝重写默认设置的问题。

