为什么要重写规则在.htaccess不会有效果吗? [英] Why RewriteRule in .htaccess does not have effect?

查看:133
本文介绍了为什么要重写规则在.htaccess不会有效果吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的Apache Web服务器在Windows 7专业版上运行。 Apache的版本就是Apache / 2.2.17(Win32的)PHP / 5.3.8。 mod_rewrite的是根据加载的phpinfo()<虚拟主机> 标记中包含 RewriteLog RewriteLogLevel 3 指令。日志文件中创建 RewriteLog 指令集。

Apache web server is running under Windows 7 professional. Apache version is Apache/2.2.17 (Win32) PHP/5.3.8. mod_rewrite is loaded according to phpinfo(). <VirtualHost> tag contains RewriteLog and RewriteLogLevel 3 directives. Log file set in RewriteLog directive is created.

的.htaccess 在根目录下的文件是以下内容:

.htaccess file in root directory is following:

RewriteEngine  On
RewriteRule ^alice\.html$ bob.html

当前目录包含 bob.html 文件,它可以打开本地主机地址。

Current directory contains bob.html file and it can be opened with localhost URL.

alice.html 网​​址不能打开,它会导致错误404。

But alice.html URL can not be opened, it causes error 404.

有关本网站日志文件包含有关找不到文件只是正常的消息。

Log file for this site contains just normal message about file not found.

重写日志文件存在,但空的。

Rewrite log file exists but empty.

这可能会导致被忽略改写指令?

Which can cause rewrite directives being ignored?

推荐答案

请确保您有这条线在你的httpd.conf:

Make sure you have this line in your httpd.conf:

AllowOverride All

的AllowOverride 控制什么指令可以被放置在.htaccess文件。

AllowOverride controls what directives may be placed in .htaccess files.

测试:要测试的.htaccess是否启用与否,只是把一些垃圾文字,看看它是否产生了500内部错误或不

Testing: To test whether .htaccess is enabled or not, just put some junk text in it and see if it generated a 500 internal error or not.

这篇关于为什么要重写规则在.htaccess不会有效果吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆