我已经在Cpanel中设置了Nodejs应用程序(在ReactJs上开发)。一切正常,除非我无法直接浏览到应用程序的任何路由。在“应用程序URL”中,我具有以下设置Application URL : subdomain.domain.com
。当我浏览到subdomain.domain.com
时,一切正常。即使当我单击某个链接以路由到subdomain.domain.com\routeA
时,它也可以正常工作。
但是,当我直接在浏览器中输入subdomain.domain.com\routeA
时,我得到了status code 500
错误。使用Application URL : subdomain.domain.com/*
也不起作用。我该怎么做到。
答案 0 :(得分:1)
您可以添加一个类似于以下内容的.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>
来源:https://dev.to/crishanks/deploy-host-your-react-app-with-cpanel-in-under-5-minutes-4mf6