简体   繁体   中英

Apache2 cgi not parsing a css link correctly in an html page

I have the following problem:
My document root is /var/www/html, where I have an index.cgi script. The script prints in the browser an html page which it reads from the directory /var/www/pages. I also have a css file located in the dir /var/www/css. When the HTML page is printed to the user, it fails to include the css.

<link rel="stylesheet" type="text/css" href="../css/log.css">

Instead of going one directory UP, the html is searching for the css file in /var/www/html/css, which is invalid.

If I manualy open the HTML page, it finds the css, so the link is supposed to be correct?

If I move the css in the /var/www/html dir, i get another error, apache tries to execute the css file because of the apache settings, I guess. Here is my apache Virt config:

        DocumentRoot /var/www/html

    <Directory /var/www/cgi-bin >
        SetHandler cgi-script
        Options ExecCGI
    </Directory> 

    <Directory /var/www/html>
        SetHandler cgi-script
        Options ExecCGI
    </Directory> 

How can I solve this, how to set the correct path for the css file?

After a lot of reading I managed to see the problem. In the config file I had to add the following:

Alias /css/ /var/www/css/

Same goes for scripts and others, linked in some way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM