如何解决角路由-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 举报,一经查实,本站将立刻删除。