启用Apache的mod_rewrite,但不工作 [英] Apache mod_rewrite enabled, but not working

查看:133
本文介绍了启用Apache的mod_rewrite,但不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作战的第二天对问题使用mod_rewrite。

Battling second day against problems with using mod_rewrite.

系统操作系统:Windows XP
HTTP服务器:Apache httpd的2.2

System OS: Windows XP HTTP server: Apache 2.2 httpd

相关夫妇从httpd.conf中

couple related lines from httpd.conf

LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
DocumentRoot "N:/Web-dev/www"

<Directory "/">
     Options Indexes +FollowSymLinks MultiViews
     AllowOverride All
     Order allow,deny
     Allow from all
</Directory>

<Directory "N:/Web-dev/www">
    Options Indexes +FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

的.htaccess包含:

.htaccess contains:

RewriteEngine on
RewriteRule ^alice.html$ bob.html

PHP的信息说:

php info says

Loaded Modules  core mod_win32 mpm_winnt http_core mod_so mod_actions mod_alias mod_asis mod_auth_basic mod_authn_default mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dir mod_env mod_include mod_isapi mod_log_config mod_mime mod_negotiation mod_setenvif mod_rewrite mod_proxy mod_php5 

这两个文件都存在,装载alice.html,它仍然加载它,在rewrite.log,它表明:

Both files are existing, loading alice.html, it still loads it, in rewrite.log, it shows:

127.0.0.1 - - [25/Apr/2011:11:01:27 +0300] [localhost/sid#7b5148][rid#2bc70b0/initial] (1) [perdir N:/Web-dev/www/] pass through N:/Web-dev/www/alice.html

我eaven试图测试,如果是读取.htaccess文件,通过添加一些jibberish重写引擎命令,它证明了:

I eaven tried to test, if it is reading .htaccess file, by adding some jibberish to rewrite engine command, and it proved:

[Mon Apr 25 10:47:04 2011] [alert] [client 127.0.0.1] N:/Web-dev/www/.htaccess: Invalid command 'ReDELETEMEwriteEngine', perhaps misspelled or defined by a module not included in the server configuration

但要做出一样的,要重写规则,改变不了什么,就像如果它忽略这些。我出的选项,该怎么办!?

But making same, to RewriteRule, changes nothing, like if it ignores those. I'm out of options, what to do!?

推荐答案

使更多的测试,我得到奇怪的结果 - 增加了RewriteEngine叙述命令之前,一些DELETEME - 它失败,错误,如果我后来添加任何东西,却忽视了它,就像如果就没有errrs!

Making more tests, I get to strange results - added some DELETEME before RewriteEngine command - it fails with error, if I add anything afterwards, it ignores it, like if there would be no errrs!

然后我记得我与正则表达式和文本分析的经验,我想知道,如果与CRLF篡改会有什么好处,与无蔽,什么是当前的文件新线符号,发现他们那里CR的。据我所知,Apache是​​基于Unix的软件,我想,这可能被误解的,所以我把它们转化为LF的,就是这样,一切都算帐!

Then I recall my experience with regex and text analysis, I wondered, if tampering with CRLF would do any good, and uncovering, what is current file new line symbols, uncovered that they where CR's. As I know, Apache is unix based software, I thought, it could misunderstood those, so I converted them to LF's and that was it, everything worked afterwards!

请注意未来 - 确保与你的编辑器(EditPlus的,记事本+ +等),您的.htaccess新行符号是多平台兼容(CRLF),或者至少是UNIX兼容(LF),如果与Apache工作

Note to future - make sure, with your editor (EditPlus, Notepad++, etc), that your .htaccess new line symbols are multiplatform compatible (CRLF), or at least unix compatible (LF), if working with apache!

这篇关于启用Apache的mod_rewrite,但不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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