问题
I'm using nuxjs to build my project and I create a page which displays place information dynamically.
when I run npm run dev
and test on http://localhost:3000/place/66bb50b7a5 is work well.
but after I run npm run generate
, I get the dist folder, I put in on MAMAP and try to run http://mysite:7074/place/66bb50b7a5, it shows 404 page not found.
My dist folder is like this
please tell me what wrong on my code and what I should do.
Thank you.
回答1:
You have to config your web server to response index.html
when receive requests like /place/66bb50b7a5
vue-router doc have example configurations for Apache, nginx, IIS...
For MAMP (apache):
- create an file name
.htaccess
in your MAMPhtdocs
folder - paste apache configuration from vue-router doc
.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>
来源:https://stackoverflow.com/questions/47384751/nuxtjs-cannot-display-dynamic-url-on-production