【问题标题】:How to adjust the base url for xampp to the folder that contains the code如何将 xampp 的基本 url 调整为包含代码的文件夹
【发布时间】:2018-03-13 08:31:40
【问题描述】:

这可能是一个愚蠢的愚蠢问题,但我希望我可以用 .htaccess 或其他东西做一个技巧。

在我的 XAMPP 结构中,我的项目位于 htdocs 下的文件夹中:

|- /htdocs
|-- /dist
|--- index.html
|--- *.js

在 index.html 中我有:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>MyApp</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <app-root></app-root>
<script type="text/javascript" src="inline.bundle.js"></script><script type="text/javascript" src="polyfills.bundle.js"></script><script type="text/javascript" src="styles.bundle.js"></script><script type="text/javascript" src="vendor.bundle.js"></script><script type="text/javascript" src="main.bundle.js"></script></body>
</html>

当我转到 http://localhost/dist 时出现一些错误,因为它在 /localhost/*.js 下找不到它正在寻找的 js 文件,有没有办法可以在 .htaccess 或其他地方进行动态重定向将基本网址指向/dist 而不是/localhost

我能想到的唯一方法是使用主机文件并拥有一个本地域(即mylocaldomain.com -> localhost/dist)但我想要更动态的东西,所以我不必为每个人都设置它localhost 下的文件夹。

可行吗?

【问题讨论】:

    标签: xampp


    【解决方案1】:

    你应该试试

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>MyApp</title>
      <base href="/">
    
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="icon" type="image/x-icon" href="favicon.ico">
    </head>
    <body>
      <app-root></app-root>
    <script type="text/javascript" src="js/inline.bundle.js"></script><script type="text/javascript" src="polyfills.bundle.js"></script><script type="text/javascript" src="styles.bundle.js"></script><script type="text/javascript" src="vendor.bundle.js"></script><script type="text/javascript" src="main.bundle.js"></script></body>
    </html>

    将所有 *.js 文件保存在名为 js 的文件夹中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多