Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 eaven tested more - 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!

I'm out of options, what to do!?

Related question

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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!

PS: Sorry for dublicate (here and stackoverflow).

share|improve this answer

Since you are explicitly referencing line start (^) and line end ($) in your pattern, maybe you simply have to add a / in your rewrite rule to match the request?

RewriteRule ^/alice.html$ bob.html
#            ^ this one

Requesting http://localhost/alice.html will send a header requesting path "/alice.html" so your pattern may not match otherwise.

share|improve this answer
    
No, example worked, when I replaced new line chars with LineFeed's. I'm pretty good with regex'es and this is not the case in bad regex. –  Deele Apr 25 '11 at 12:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.