php - React-Router's BrowserHistory, not accessible directly
大家讲道理
大家讲道理 2017-06-05 11:07:46
0
1
798

There is a React project that uses BrowserHistory and is placed on the Apache server. The project homepage is localhost:8081/home.

After I enter the homepage, I can jump to other subpages (subroutes), such as: localhost:8081/product

But the browser cannot access localhost:8081/product directly because the Apache server will parse this path

I can only access localhost:8081/#/product.

Is there any way to access it directly?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
習慣沉默

Forward all requests to index.html

Configure .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.html$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.html [L]
 </IfModule>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template