M
M
Maxim2019-01-08 22:53:20
PHP
Maxim, 2019-01-08 22:53:20

Hello, can you please tell me how to implement the entry to the component page right away?

Good evening. Maybe not a very right question, but the fact is that I do not know how to ask it more precisely. I'll show you an example.
There are routes:

export default (
  <div>
        <Route exact path='/' component={Home} />
        <Route path='/auth' component={Auth} />
        <Route path='/photo/:id' component={DetailPhoto} />
    </div>
);

and there is actually a router.
ReactDOM.render(
  <Router>
    {routes}
  </Router>,
    document.querySelector('#app')
);

how to make it possible to initially go to site.com/auth so that the component is rendered?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Multigame, 2016-04-06
@Kennius

It is optimal to store not absolute links in the database, but relative paths.
And so there are many options, at least the notorious replay for the sample.

V
Viktor Taran, 2016-04-07
@shambler81

on the site-msc.ru site you write redirects and that's it,
although of course you need to run the database regularly and delete this file

M
Maxim, 2019-01-09
@MaxGraph

Maybe not everyone understood me, but I found the answer.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.html$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.html [L]
 </IfModule>

This htaccess worked, now all requests go to index.html, and already there the react itself renders what is needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question