无法识别Apache PHP相对路径


Apache PHP relative path not recognised

我一直在安装Ushahidi平台客户端。我让API工作感谢mod重写。现在我正在建立平台客户端,但我没有成功。

下面是我的html文档设置:

html
 nbsp index.html
 nbsp about.html
 nbsp 平台客户端<~子目录
 nbsp nbsp nbsp 服务器
 nbsp nbsp nbsp www
 nbsp nbsp nbsp nbsp nbsp htaccess
 nbsp nbsp nbsp nbsp nbsp index.html

这是我的平台客户端中的.htaccess

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ /index.html  [PT,L]

这里是平台客户端/服务器/www/index.html:

<!doctype html>
<html lang="en" ng-strict-di>
<head ng-controller="PageMetadata">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="/fonts/Lato/css/fonts.css" rel="stylesheet" type="text/css">
    <!-- @todo minify CSS -->
    <link rel="stylesheet" href="/css/style.css" ng-href="{{rtlEnabled ? '/css/rtl-style.css' : '/css/style.css'}}">
    <link rel="stylesheet" href="/css/vendor.css">
    <script src="/config.js"></script>
    <title ng-bind-template="{{pageTitle}} {{siteTitle}}"></title>
    <meta name="description" content="{{pageDescription}}">
    <meta name="keywords" content="{{pageKeywords}}">
    <meta name="robots" content="{{pageRobots}}">
    <base href="/">
</head>
<body ng-class="{ rtl : rtlEnabled }" class="has-dynamic-header" canvas>
    <div id="bootstrap-loading">
        <header class="header header-full overlay" role="banner">
            <div class="container">
                <div class="color-overlay">
                    <div class="parallax">
                        <h1 class="beta"><i class="fa fa-refresh fa-4 fa-spin"></i></h1>
                    </div>
                </div>
            </div>
        </header>
    </div>

等等。。。。

当我运行网站时,我得到的是错误显示,而不是正确的。当我检查元素时,我发现/css/style.css指向我的根目录,也就是域。

 www.example.com/css/style.css

应该是:

www.example.com/platform-client/server/www/css/style.css

更新:这是我的httpd.conf:

NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName example.com
ServerAlias www.example.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@example.com
DocumentRoot /var/www/html/platform-client/server/www
ServerName example.com/platform-client/server/www
<Directory "/var/www/html/platform-client/server/www">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
</VirtualHost>

我的设置有什么问题吗?我真的需要你的帮助,因为我已经修复了将近一个星期,但没有成功。我很乐意接受任何帮助。谢谢

因此,要解决此问题,请将以下A记录添加到DNS条目中:

*    A    <your host's ip-address>

您的域的每个可能的子域现在都将指向同一主机。您的主机提供商可能允许您通过一些配置面板(如cpanel)添加DNS条目。如果他们这样做了,要小心你的改变。做出错误的更改可能会让您的主机停播数小时。如果他们不允许"*"作为您的子域,那么只需输入您需要的特定子域即可。

然后,在httpd.conf中包含以下两个VirtualHosts-理想情况下,将其包含在/etc/apache2/sites-enabled文件夹中,但您可能会担心以后会美化您的配置:

<VirtualHost *:80>
    ServerAdmin webmaster@<yourdomain>.com
    DocumentRoot /var/www/html
    ServerName www.<yourdomain>.com
    ServerAlias <yourdomain>.com
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@<yourdomain>.com
    DocumentRoot /var/www/html/platform-client/server/www
    ServerName <subdomain>.<yourdomain>.com
</VirtualHost>

理想情况下,您还应该将两个文件夹结构分开,使它们看起来像这样:

/var
    /www
        /<yourdomain>.com
            /www
                /htdocs
                    index.html and everything
                        else for your default
                        website goes here
            /<subdomain>
                /htdocs
                    index.html and everything
                        else for your Ushithingy
                        installation goes here

并相应地调整虚拟主机中的文档根。你应该这样做的原因是,只要一个网站在另一个网站的docroot内,仍然可以通过第一个虚拟主机定义访问第二个网站——只有这样,页面才会因为不同的docroot和页面中的绝对href而看起来一团糟。有序目录结构的另一个优点是,您可以使用mod_vhost_alias通过一个简单的虚拟主机定义为许多子域定义网站。但再说一遍,那是以后的事。

如果完成了,请重新启动apache服务器,一切都会好起来。