Trying to learn how to setup virtual hosts on Apache2.4.
I have 2 or more virtual hosts, "vhost1", "vhost2", and so on. These virtual hosts have a "index.html" in their DocumentRoot, and a "step2.cgi" in their {DocumentRoot}/cgi-bin directory.
The goal is that from the index.html in the DocumentRoot, I want to click on the link contained in that index.html to go to the vhost's cgi-bin directory and run a script from there.
The issue I'm seeing is if I click on the link in the index.html, the link tries to open the indicated file in the default server's DocumentRoot. And, gets an "error 404" in response.
How do I get a link a relative URL to activate the cgi in the cgi-bin directory of the virtual host that I started with?
I note that if I have a link in the index.html that just refers to "step1.html", that page is correctly display.
What am I doing wrong? Thanks!
I have a virtual host with the configuration:
<VirtualHost *>
DocumentRoot /srv/www/vhosts/vhost1/htdocs
ServerName vhost1.local
ServerAlias vhost1
ServerAdmin [email protected]
<Directory /srv/www/vhosts/vhost1/htdocs/>
DirectoryIndex index.cgi
DirectoryIndex index.html
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
AllowOverride None
Options +ExecCGI -Includes
Require all granted
</Directory>
<Directory /srv/www/vhosts/vhost1/cgi-bin/>
DirectoryIndex index.cgi
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
AllowOverride None
Options +ExecCGI -Includes
Require all granted
</Directory>
CustomLog /srv/www/vhosts/vhost1/logs/access_log vhost_common
ErrorLog /srv/www/vhosts/vhost1/logs/error_log
</VirtualHost>
The index.html looks like:
<html>
<head>
<title>
My page title
</title>
</head>
<body>
<a href="http://vhost1.local/cgi-bin/step2.cgi">
Click here:
</a>
<a href="step1.html">
or here:
</a>
</body>
</html>
And the error in the error_log file is:
[Sun Oct 20 00:33:37.611844 2019] [cgi:error] [pid 3770] [client 192.168.0.103:63367] AH02811: script not found or unable to stat: /srv/www/cgi-bin/step2.cgi, referer: http://vhost1.local/