【问题标题】:CSS/Javascript Testing IssuesCSS/Javascript 测试问题
【发布时间】:2013-04-11 22:18:41
【问题描述】:

好的,这有点冗长,但这是问题所在......

我正在测试一个运行 PHP 5.4.11 的 Apache 2.4.3 网络服务器,但在显示 css 菜单和 javascript 的某些页面上遇到了问题。我说我不是网页设计者,只是服务器小兵...开发者在不同页面上使用了绝对路径和相对路径来调用css和javascript。测试时,使用绝对路径的页面不显示css菜单,也不运行javascript,但使用相对路径的页面会。可能使事情复杂化,我在服务器上运行两个基于名称的虚拟主机,该问题仅在 Domain1 上表现出来,辅助域不使用这些功能。当我在使用本地主机的服务器上或从具有在主机文件中定义的域的笔记本电脑上进行测试时,就会发生这种情况。我不确定这是否与我测试站点的方式、站点的配置或两者的组合有关。 css调用,配置文件如下:


来自有效网页的 css 调用:

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

文件位于:Document Root/domain1/Folder1/index.php


来自不起作用的网页的 css 调用:

<link href="http://www.domain1/css/cu.css" rel="stylesheet" type="text/css"/>
<script src="AC_RunActiveContent.js" type="text/javascript"></script> <style type="text/css">

文件位于:Document Root/domain1/index.php(domain1主网页)


httpd-vhost.conf:

<VirtualHost *:80>

ServerName www.domain1.com
DocumentRoot "/Document Root/domain1"
ServerAdmin admin@domain1.com
ScriptAlias /cgi-bin /Server Root/cgi-bin/
ErrorDocument 404 /domain1/error/404.php
ErrorLog logs/domain1-error_log
CustomLog logs/domain1-access_log common

<Directory "/var/www/html/domain1">
AllowOverride All 
Options FollowSymLinks 
Require all granted
</Directory>

<Directory "/Document Root/domain1/images">
AllowOverride All 
Options FollowSymLinks 
Require all granted
</Directory>

<Directory "/Document Root/domain1/includes">
AllowOverride All 
Options All
Require all granted
</Directory>

<Directory "/Document Root/domain1/css">
AllowOverride All 
Options All
Require all granted
</Directory>

</VirtualHost>


<VirtualHost *:80>

ServerName www.domain2.com
DocumentRoot "/Document Root/domain2/cuss"
ServerAdmin admin@domain2.com
ErrorDocument 404 /domain2/error/404.php
ErrorLog logs/domain2-error_log
CustomLog "logs/domain2-access_log" common

</VirtualHost>

.htaccess 文件:文件位于:Document Root/domain1/

DirectoryIndex index.php index.html

Options +FollowSymLinks

RewriteEngine On

RewriteRule ^faq.php http://www.domain1/faq [L]

CheckSpelling on

服务器上的主机文件:

127.0.0.1   localhost.domain    localhost
:1  www.domain1.com localhost6.domain   localhost6
<server ip address> www.domain1.com
<server ip address> www.domain2.com

测试笔记本电脑上的主机文件:

127.0.0.1       localhost
<server ip address> www.domain1.com
<server ip address> www.domain2.com

我需要尽快将此服务器投入生产!有没有人知道如何测试它以确保它在上线时都能正常工作?提前致谢!

【问题讨论】:

    标签: php css apache


    【解决方案1】:

    这里看起来是同一个问题:How to use relative/absolute paths in css URLs?

    我认为您只需将生产链接更改为:

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

    因为 css 文件夹和 index 文件在同一级别。

    【讨论】:

    • 我即时更改了文件,但它仍然无法正常工作。同一个网站在现有的生产服务器上运行,并且运行良好。我已经复制了它的配置,唯一的区别是新的是一个虚拟主机,而生产是一个独立的站点。
    • 但它的托管地点和方式并不重要。也许您可以检查它尝试从哪里加载 css 文件? Chrome networking tutorial
    • 我可能找错了树。我想我应该致力于使 Apache 服务器配置与页面一起工作,而不是相反。
    • 我已经决定解决这个问题的最佳方法,因为我找不到服务器端的解决方案是让网页设计师更改他们的代码以使用相对路径。感谢所有试图提供帮助的人。
    猜你喜欢
    • 1970-01-01
    • 2010-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    相关资源
    最近更新 更多