PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, February 17, 2022

[FIXED] MAMP Apache Alias always maps relative to document root

 February 17, 2022     alias, apache, mamp, mapping     No comments   

Issue

I'm trying to setup a virtual directory in Apache on MAMP.

This is what I'm putting in the httpd.conf file

  Alias /app /Users/ernesto/Developer/App/webroot
  <Directory /Users/ernesto/Developer/App/webroot>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>

MAMP's document root is set to the default /Applications/MAMP/htdocs and the path in the example above is meant to be absolute. But MAMP is trying to map the above path to:

/Applications/MAMP/htdocs/Users/ernesto/Developer/App/webroot

I realized this after displaying the last few lines of apache's error log:

[Thu Nov 17 15:40:39 2011] [error] [client 127.0.0.1] File does not exist: /Applications/MAMP/htdocs/Users

Just ot be sure, I changes the path above to start with /Uxers (instead of /Users), and the change was reflected in the error log.

I'm almost sure from what I've researched online that what I expect is the correct behavior, but obviously I might be doing something wrong, or maybe there's some other obscure setting in MAMP's httpd.conf that is making apache work this way. Any ideas?


Solution

So.. from this SO question I got that there are some issues with using both alias and mod_rewrite. Which led me to this part of the Apache manual which states:

#
#  /abc/def/.htaccess -- per-dir config file for directory /abc/def
#  Remember: /abc/def is the physical path of /xyz, i.e., the server
#            has a 'Alias /xyz /abc/def' directive e.g.
#

RewriteEngine On

#  let the server know that we were reached via /xyz and not
#  via the physical path prefix /abc/def
RewriteBase   /xyz

#  now the rewriting rules
RewriteRule   ^oldstuff\.html$  newstuff.html

Adding a rewrite base to the .htaccess file in the aliased directory solved my issue (which led me to your question in the first place)



Answered By - danneth
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing