1

I'm working with an Apache rewrite statement that reads:

RewriteRule ^((?!%{HTTP_HOST}).*)$ ${US_ROOTF_WWW}/www.%{HTTP_HOST}%{REQUEST_URI} [L,E=PROJECT_PREPENDED:1]

The value of {US_ROOTF_WWW} is C:/Chipster/ChipsterContent

The Apache log reports the Web root location translated to:

/C:/Chipster/ChipsterContent/bubbah.org/

Note the slash at the beginning.

Where does this rascal come from?

5
  • What is your intended purpose for this rule? You usually would rewrite to a path within the document root, not to an absolute path. Sep 6, 2022 at 18:23
  • Yes, I'm using all relative links. The root of the Web documents is defined once in my WAMP (Uniform Server) and stored in the {US_ROOTF_WWW} variable.
    – missenc
    Sep 6, 2022 at 21:21
  • My point is that because the variable is there the link is not relative. Why don't you just omit the variable altogether? Sep 6, 2022 at 23:01
  • Thanks! THe US_ROOT_WWW variable is indeed relative. The Web root folder is dynamically garnered from the Uniform Server conf file (itself relative to the Apache executable.) The Apache logs show the end result as full path. I tried a couple experiments without the variable and got interesting results. I'm heading down that rabbit hole now...
    – missenc
    Sep 8, 2022 at 1:13
  • "THe US_ROOT_WWW variable is indeed relative." - Although that doesn't look like the intention, as this "looks like" an absolute filesystem path on a Windows server? However, Apache "mod_rewrite" will certainly see this as a relative-path. But where is /bubbah.org/ coming from - your directive contains /www.? Where exactly are you using this rule (I assume .htaccess or <Directory> container in the document root?) Your RewriteRule pattern is also "incorrect" and is not doing what you think it's doing. You need to state what it is you are trying to do.
    – MrWhite
    Sep 8, 2022 at 1:28

1 Answer 1

0

Apache is probably thinking the path is relative because not starting with what it expects to be as an absolute path, which is most probably C:\Chipster\ChipsterContent instead of using forward slashes.

Apache documentation at https://httpd.apache.org/docs/2.4/platform/windows.html seems inconclusive/inconsistent:

The directives that accept filenames as arguments must use Windows filenames instead of Unix ones. However, because Apache may interpret backslashes as an "escape character" sequence, you should consistently use forward slashes in path names, not backslashes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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