Pizhev Racing
Pizhev Racing

Reputation: 486

How to access subfolder in htdocs in apache server with react

When I build some app on react and put in htdocs everything work fine.

I create a folder with name "todo" in htdocs and paste build files in the second react project and when I want to access this folder localhost/todo/ I cannot see the project.

Can I get some hint how to fix that ?

Upvotes: 0

Views: 901

Answers (1)

blankart
blankart

Reputation: 716

Update your basename in your Router and build the app again.

<Router basename={'/todo'}>
  <Route path={`${process.env.PUBLIC_URL}/`} component={Home} />
  <Route path={`${process.env.PUBLIC_URL}/news`} component={News} />
  <Route path={`${process.env.PUBLIC_URL}/about`} component={About} />
</Router>

You may refer to this link to fully change your webpack routes.

Upvotes: 1

Related Questions