I have an index.html in my /Users/igor/Sites/MySite folder (igor is my username on Mac). Links (for example: <a href="/page">Page</a>) all go to localhost/page instead of http://localhost/~igor/MySite/page. http://localhost reports It works!, in http://localhost/~igor/ I see all my files and folders.
My /private/etc/apache2/users/igor.conf file:
<Directory "/Users/igor/Sites/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
</Directory>
My /private/etc/apache2/extra/httpd-userdir.conf file (without comments):
UserDir Sites
Include /private/etc/apache2/users/*.conf
<IfModule bonjour_module>
RegisterUserSite customized-users
</IfModule>
Also I uncommented lines in httpd.conf as described here.
Some lines from my httpd.conf:
User _www
Group _www
<Directory />
AllowOverride none
Require all denied
</Directory>
<Directory "/Library/WebServer/Documents">
Options FollowSymLinks Multiviews
MultiviewsMatch Any
AllowOverride None
Require all granted
</Directory>
httpd -V output:
Server version: Apache/2.4.23 (Unix)
Server built: Aug 8 2016 16:31:34
Server's Module Magic Number: 20120211:61
Server loaded: APR 1.5.2, APR-UTIL 1.5.4
Compiled using: APR 1.5.2, APR-UTIL 1.5.4
Architecture: 64-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_FLOCK_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/usr"
-D SUEXEC_BIN="/usr/bin/suexec"
-D DEFAULT_PIDLOG="/private/var/run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="/private/etc/apache2/mime.types"
-D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"
How to fix links so they correspond to Sites/MySite/MyLink and not localhost/MyLink? Thanks.
Update: httpd -t -D DUMP_RUN_CFG returns:
[Thu Oct 13 16:55:24.277291 2016] [so:warn] [pid 46810] AH01574: module php5_module is already loaded, skipping
AH00112: Warning: DocumentRoot [/usr/docs/dummy-host.example.com] does not exist
AH00112: Warning: DocumentRoot [/usr/docs/dummy-host2.example.com] does not exist
ServerRoot: "/usr"
Main DocumentRoot: "/Library/WebServer/Documents"
Main ErrorLog: "/private/var/log/apache2/error_log"
Mutex default: dir="/private/var/run/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/private/var/run/httpd.pid"
Define: DUMP_RUN_CFG
User: name="_www" id=70 not_used
Group: name="_www" id=70 not_used
httpd.confyou need to reference the directives (like DocumentRoot). Directives can be located anywhere in httpd.conf and httpd.conf files differ by distro, Apache version and by user so line numbers don't help. – Allan Oct 13 '16 at 12:38/Library/WebServer/Documents/. Execute this command:httpd -t -D DUMP_RUN_CFGand post the results. – Allan Oct 13 '16 at 13:27httpd.confyour DocumentRoot is not set properly becausehttpddoesn't have the correct value. See the value "Main Document Root". You will need to go through your httpd.conf files (including the custom ones) and make sure you are setting the directive properly; there should be only one and should only be in the main `httpd.conf' – Allan Oct 13 '16 at 14:09DocumentRootand<Directory ... >should beUsers/igor/Sites/? – Igor R. Oct 13 '16 at 14:27httpd.confmake it the directory where you want the root of your website to be. – Allan Oct 13 '16 at 14:50Users/igor/Sites/to/Users/igor/Sites/. That fixed it. – Igor R. Oct 13 '16 at 14:59