Thursday, April 16, 2015

apache 2.2 - Rewrite not working in htaccess (apache2.2.22, windows server 2012)



I'm sure that my .htaccess file is being read by Apache as I tried to write in random stuff in it, eg: "sifnoweijf", and my page could no longer be displayed.




but why the following rewrite doesn't work?



Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_METHOD} ^(CONNECT|OPTIONS)
RewriteRule .* - [R=405,L]




  • Running Apache 2.2.22 on Windows Server 2012

  • .htaccess file in DocumentRoot, eg: "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs"

  • httpd.conf is configured:



    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all




Anyone?


Answer




Sorry guys, the rewrite is definitely working.



As you guys can see on my rewrite condition, I'm trying to respond to the CONNECT and OPTIONS request method with HTTP respond code 405. But I'm still getting respond code 200.



The culprit is my network's configuration where the hardware load-balancer is responding on behalf of the web server.



So, having the load-balancer configured properly fixed the issue.



Case Solved


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...