Hash
location ^~ /路径名 {
try_files $uri $uri/ /路径名/index.html;
}
History
普通域名正常解析
location ^~ /tw {
index index.html index.htm;
try_files $uri $uri/ /tw/index.html;
}
前端路由控制
const router = createRouter({
history: createWebHistory(import.meta.env.VITE_ROUTER_URL),
routes,
});
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import Components from "unplugin-vue-components/vite";
import { NaiveUiResolver } from "unplugin-vue-components/resolvers";
const pathSrc = path.resolve(__dirname, "src");
export default defineConfig({
base: process.env.NODE_ENV === 'development' ? '/' : './',
resolve: {
alias: {
"@/": `${pathSrc}/`,
},
},
plugins: [
vue(),
Components({
resolvers: [NaiveUiResolver()],
}),
],
});
子域名重定向