【发布时间】: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