# Solved: Perl CGI <body> tag with background-image



## andynic (May 25, 2007)

Hi,

I have coded a simple form using Perl CGI using an Apache Server.

The code contains the following construct:
my $formNm = "getLoginInfo";

my $bodyDef = "";

my $formDef = "";

For some reason the background image does not display.

If however, I use right-click --> View Source and then save the code into, for example x.html, when I double-click x.html, the image displays as wanted.

I have run x.html through the validator at 
http://validator.w3.org/#validate_by_upload 
and it shows no errors.

Why would this not work via CGI?

Might it have something to do with the entries in the Apache httpd.conf file? In the cgi script, I have tried changing 
background-image:url(\"images/gfrm/Geof_head_1468x992.jpg\");
to
background-image:url(\"/gfr-bin/Geof_head_1468x992.jpg\");
and putting the jpg in the /gfr-bin/ directory. (everything runs from /gfr-bin/). This did not work either.

Anyone have any ideas?
Thanks for your help.
Andynic
Windows XP service pack 3
Perl 5.10
Apache Server 2.2
Internet Explorer 7, Safari 3.2.2, Firefox 5


----------



## andynic (May 25, 2007)

I have figured out what I am doing wrong. It does lie with the Apache Server configuration.

I've found two alternatives to correct this:

Alternative A:
==========

1. In the Apache server (on my Windows system: C:\Program Files\Apache Software Foundation\Apache2.2) edit the file in the sub-directory conf\extra\httpd-autoindex.conf
Note the entry:
Alias /icons/ "C:/Program Files/Apache Software Foundation/Apache2.2/icons/"

<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

2. Edit the file conf\httpd.conf and find the entry near the bottom of the file:
# Fancy directory listings
# Include conf/extra/httpd-autoindex.conf

3. Change it to:
# Fancy directory listings
Include conf/extra/httpd-autoindex.conf

4. Put the image files in the /icons/ directory defined in (1) above

5. Change the body style 
background-image: url('/icons/fileName.ext');

The same holds for <IMG src= > tags.

Alternative B:
==========
Alternatively, instead of doing 1, 2, 3 above, you can add an entry like this directoy to the httpd.conf file:
Alias /icons/ "C:/subdir1/subdir2/etc/icons/"
<Directory "C:/subdir1/subdir2/etc/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

In my case I placed it just above the section of the httpd.conf file that looks like this:
#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#

Then put the image file in this /icons/ directory and modify the "background-image" attributes and "<img src=" attributes accordingly.

Greetings,
Andynic


----------

