Apache mod_rewrite enabled, but not working

谁都会走 提交于 2020-01-02 07:24:22

问题


Battling second day against problems with using mod_rewrite.

System OS: Windows XP HTTP server: Apache 2.2 httpd

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 contains:

RewriteEngine on
RewriteRule ^alice.html$ bob.html

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 

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

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!?


回答1:


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!

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!

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!



来源:https://stackoverflow.com/questions/5776509/apache-mod-rewrite-enabled-but-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!