【发布时间】:2021-11-26 13:14:41
【问题描述】:
我的 Next.js 应用程序出现重定向问题。
我做了静态导出 (next build && next export)。
应用程序的主机位于子目录中(https://www.myhost.com/subdirectory/**[index.html 这里]**)所以我在next.config.js 中使用了basePath: '/subdirectory'。
一切都一见钟情。
在应用程序内重定向工作正常。但是当用户刷新另一个页面上的页面然后索引时 - 假设页面名为 subpage (https://www.myhost.com/subdirectory/subpage) 该站点不会将用户重定向到子页面而是转到 https://www.myhost.com/ (甚至到项目所在的子目录)。
非常感谢有人的帮助。
这是.htaccess 文件。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html/ [L]
</IfModule>
如果你需要任何其他文件,如果你评论它,我可以编辑这篇文章。
提前致谢!!
【问题讨论】:
标签: javascript .htaccess redirect next.js