5

I'm using nuxjs to build my project and I create a page which displays place information dynamically.

enter image description here

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

enter image description here

please tell me what wrong on my code and what I should do.

Thank you.

1
  • Did you every find a solution to the problem? Commented Mar 3, 2020 at 10:49

2 Answers 2

9

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):

  1. create an file name .htaccess in your MAMP htdocs folder
  2. 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>
Sign up to request clarification or add additional context in comments.

1 Comment

@GEOFFREYMWANGI, this should do the job, have you tried this or not?
0

I've had the same problem and I've solved it.

my case in apache:

  1. create .htaccess file in the same folder as index.html
  2. copy-paste the following script, and all works charmly.
<IfModule mod_rewrite.c>
  Rew/riteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

Previously I found this script on github

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.