角路由-Apache子文件夹

问题描述

我将我的应用程序部署到了我的Apache服务器文件夹中,一切正常进行。之后,我尝试将项目移至子文件夹,并相应地更改了.htaccess和base href,并且动态URL路由停止工作。

路线

const appRoutes: Routes = [
  { path: "config",component: ConfigComponent },{ path: "preview/:id",component: PreviewComponent },];

根文件夹:

index.html:

 <base href="/">

.htaccess

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . index.html [L]
</IfModule>

URL:

http://localhost/config -- Works as intended
http://localhost/preview/5f439152432f521e38f5ce2f -- Works as intended

子文件夹:

index.html:

 <base href="./">

.htaccess

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /subfolder
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . index.html [L]
</IfModule>

URL:

http://localhost/subfolder/config -- Works as intended
http://localhost/subfolder/preview/5f439152432f521e38f5ce2f -- Does not work

错误:

未加载预览组件,并且在浏览器控制台上显示以下错误:

由于不允许的MIME类型(“ text / html”),阻止了从“ http:// localhost / subfolder / preview / polyfills(...).js”加载模块。

可能是什么? .htaccess RewriteRules中缺少其他内容吗?

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...