Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have the following virtual host file:

<IfModule !wsgi_module>
  LoadModule wsgi_module modules/
  WSGISocketPrefix run/wsgi

<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 *:443>

  RewriteEngine  on
  RewriteRule    ^docs$  docs/  [R]
  # SSL & WSGI Setup

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?

share|improve this question

marked as duplicate by MadHatter, mdpc, Nixphoe, MichelZ, Jenny D May 13 '14 at 13:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

@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 Answer 1

up vote 3 down vote accepted

As per

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]
share|improve this answer

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