3

I'm trying to redirect calls to my Apache 2.4 virtual host (Wampserver 2.5) that match a certain pattern to a directory outside of my DocumentRoot. Here is the relevant code from my .conf file:

<VirtualHost *:80>
    ServerName testserver.dev
    DocumentRoot "D:\Path\to\webserver\public\build"

    RewriteEngine On
    LogLevel alert rewrite:trace6

    # Statement below results in 404
    AliasMatch "^/sitemap.\d+.xml.gz$" "D:\Path\to\webserver\private\index.php"
</VirtualHost>

When I make a call to apache such as http://testserver.dev/sitemap.1.xml.gz I get a 404 returned from the server. From what I can tell the match is actually working so I'm assuming the directory path is somehow configured wrong? If I hardcode it and use just plain Alias it works as intended:

# This works below
Alias /sitemap.1.xml.gz "D:\Path\to\webserver\private\index.php"

Not sure what I'm doing wrong. I have logging enabled and this is what shows up in the error log:

init rewrite engine with requested uri /sitemap.1.xml.gz
pass through /sitemap.1.xml.gz

And in the access log for the requests that don't work

"GET /sitemap.1.xml.gz HTTP/1.1" 404 304

Anyone have any idea? I figure this has to be something simple I'm overlooking.

Scott
  • 948
  • 2
  • 13
  • 25

1 Answers1

2

I figured this out after realizing I wasn't seeing the Alias logging.

First I added this LogLevel:

LogLevel debug alias:trace6

Which allowed me to see that when it was trying to replace the regular expression matches (which i'm not using) the backslashes were being removed in my target directory. Since I'm on Windows I changed the path to the following:

D:/Path/to/webserver/private/index.php

And it now maps the path as intended.

Scott
  • 948
  • 2
  • 13
  • 25