0

I have the following virtual host file:

<IfModule !wsgi_module>
  LoadModule wsgi_module modules/mod_wsgi.so
  WSGISocketPrefix run/wsgi
</IfModule>

<VirtualHost *:80>
  RewriteEngine On
  RewriteLog "/var/log/httpd/rewrite_log"
  RewriteLogLevel 1
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]
</VirtualHost>

<VirtualHost *:443>
  ServerName https://tendril-api.dev.adnxs.net
  ServerAlias 06.tendril-api.dev.nym2.adnexus.net/api

  RewriteEngine  on
  RewriteRule    ^docs$  docs/  [R]
  ... 
  # SSL & WSGI Setup
</VirtualHost>

For some reason, My docs Rewrite rule isn't taking effect at all. Why is this? My HTTP-->HTTPS rewrite rule in the *:80 VirtualHost works properly. I am doing something really similar.

Does it have to do with having two different Rewrite rules in different VirtualHosts?

Any ideas?

darksky
  • 135
  • 5
  • @MadHatter I've read, and followed that guide. If you look at my rules, they conform with the documentation for mod_write. – darksky May 12 '14 at 22:46
  • Your question is tagged both `apache-2.2` and `apache-2.4`. If you're running 2.4 you should go read the apache mod_rewrite docs again; there may habe been some changes. – Jenny D May 13 '14 at 13:52

1 Answers1

3

As per http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule:-

What is matched?

In VirtualHost context, The Pattern will initially be matched against the part of the URL after the hostname and port, and before the query string (e.g. "/app1/index.html").

Your pattern is matching an exact URL of "docs". The actual URL is probably "/docs", so adding a "/" after the "^" may work:-

RewriteRule    ^/docs$  docs/  [R]
Andy Smith
  • 1,798
  • 13
  • 15