如何调试的.htaccess重写规则不工作

编程入门 行业动态 更新时间:2024-10-25 07:31:15
本文介绍了如何调试的.htaccess重写规则不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在未进行任何操作,的.htaccess 文件有一个重写规则。我该如何解决呢?

I have a RewriteRule in a .htaccess file that isn't doing anything. How do I troubleshoot this?

  • 如何验证,如果的.htaccess 甚至被阅读和遵守Apache的文件?我可以写一个回声这是工作的消息,如果我不写,哪里会该行呼应了?
  • 如果不被使用的的.htaccess 文件,我怎么才能让Apache使用它?
  • 如果在的.htaccess 正在使用的,但我的重写规则仍然没有效果,还有什么可我做的调试?
  • How can I verify if the .htaccess file is even being read and obeyed by Apache? Can I write an echo "it is working" message, if I do write it, where would that line be echoed out?
  • If the .htaccess file isn't being used, how can I make Apache use it?
  • If the .htaccess is being used but my RewriteRule still isn't having an effect, what more can I do to debug?
推荐答案

输入一些垃圾值到的.htaccess 例如富栏, sakjnaskljdnas 不被认可htaccess的任意关键字并访问您的网址。如果是工作,你应该得到一个

Enter some junk value into your .htaccess e.g. foo bar, sakjnaskljdnas any keyword not recognized by htaccess and visit your URL. If it is working, you should get a

500内部服务器错误

500 Internal Server Error

服务器遇到一个内部错误或配置错误,无法完成您的请求......

The server encountered an internal error or misconfiguration and was unable to complete your request....

我建议你把它后不久 RewriteEngine叙述上。

因为你是你的机器上。我presume您可以访问到Apache .conf文件文件。

Since you are on your machine. I presume you have access to apache .conf file.

打开 .conf文件文件,查找类似的行:

open the .conf file, and look for a line similar to:

LoadModule rewrite_module modules/mod_rewrite.so

如果是被注释掉(#),取消并重新启动Apache。

If it is commented(#), uncomment and restart apache.

要改写记录

RewriteEngine On RewriteLog "/path/to/rewrite.log" RewriteLogLevel 9

把上面的3条线在你的虚拟主机。重新启动httpd的。

Put the above 3 lines in your virtualhost. restart the httpd.

RewriteLogLevel 9 使用了水平很高的价值将显着减慢你的Apache服务器!使用重写日志文件在一个水平仅大于2的调试!9级将记录几乎每一个细节rewritelog

RewriteLogLevel 9 Using a high value for Level will slow down your Apache server dramatically! Use the rewriting logfile at a Level greater than 2 only for debugging! Level 9 will log almost every rewritelog detail.

事情已经在Apache的2.4改为:

Things have changed in Apache 2.4:

从2.2 升级到2.4

FROM Upgrading to 2.4 from 2.2

在 RewriteLog 和 RewriteLogLevel 指令已被删除。此功能现在由使用的LogLevel 指令配置日志的适当水平的mod_rewrite的模块提供。又见mod_rewrite的记录部分。

The RewriteLog and RewriteLogLevel directives have been removed. This functionality is now provided by configuring the appropriate level of logging for the mod_rewrite module using the LogLevel directive. See also the mod_rewrite logging section.

有关更多的LogLevel,请参阅 LogLevel指令

For more on LogLevel, refer LogLevel Directive

您可以完成

RewriteLog "/path/to/rewrite.log"

在这种方式现在

LogLevel debug rewrite_module:debug

更多推荐

如何调试的.htaccess重写规则不工作

本文发布于:2023-11-16 18:22:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1606702.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   规则   工作   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!