title: Configuring react router for apache subdomain
body: <p>Hello I am  experimenting with react router, I have developed 3 &quot;pages&quot; and I want to deploy this app to a server at a subdomain. My problem is that I cannot make the react router to work as I expected. I want my app to work at a particular URL. I am not sure if have understood the principles of routing correctly. I am making my test on XAMP. I have implemented a basic react router through browserRouter but I have several issues.</p>
  <p>To begin with here is my main component and the routing:</p>
  <pre><code>&lt;Router &gt;
      &lt;nav className='blue-grey darken-3'&gt;
        &lt;div className=&quot;blue-grey darken-3nav-wrapper&quot;&gt;
          &lt;ul id=&quot;nav-mobile&quot; className=&quot;&quot;&gt;
            &lt;li&gt;&lt;Link to=&quot;/&quot;&gt;Home&lt;/Link&gt;&lt;/li&gt;
            &lt;li&gt;&lt;Link to=&quot;/creation&quot;&gt;Creation form&lt;/Link&gt;&lt;/li&gt;
          &lt;/ul&gt;
        &lt;/div&gt;
      &lt;/nav&gt;
  
      &lt;div className='mainContainer'&gt;
          &lt;Switch&gt;
            &lt;Route exact path=&quot;/&quot;&gt;
              &lt;HomePageComponent/&gt;
            &lt;/Route&gt;
            &lt;Route exact path=&quot;/user/:id&quot;&gt;
              &lt;UserPageComponent/&gt;
            &lt;/Route&gt;
            &lt;Route path=&quot;/creation&quot;&gt;
              &lt;UserCreationPageComponent/&gt;
            &lt;/Route&gt;
          &lt;/Switch&gt;
      &lt;/div&gt;
  &lt;/Router&gt;
  </code></pre>
  <p>I have deployed my app to a localhost subdomain called</p>
  <blockquote>
  <p>/reactTest</p>
  </blockquote>
  <p>so the I access the app using</p>
  <blockquote>
  <p>localhost/reactTest</p>
  </blockquote>
  <p>If I navigate around using the links in the app everything works as expected. However I have several problems:</p>
  <p>I was expecting that if I would access a url like directly on the browser <code>localhost/reactTest/creation</code>, I would be navigated to the creation component. Instead I receive a 404 error.</p>
  <p>Also, when I navigate using the app's links I see that the domain is discarded. So for example when I click the creation page link, instead of navigating to <code>localhost/reactTest/creation</code> I am navigated to localhost/creation which works fine, though it doesn't seem correct to me. Again if try to navigate to it be accessing it directly from the browser it doesn't work.</p>
  <p>I also tried to set basename to the router by replacing <code>&lt;Router &gt;</code> with  <code>&lt;Router  basename=&quot;/reactTest&quot;&gt;</code>. That solved the issue with the 'vanishing' subdomain so I was correctly navigated to a page withought losing the 'reactTest' part of the url, but accessing it outside the app still isn't possible.
  Is all that the expected behaviour? Is there a way to achieve navigation the way I describe it above?</p>
  <p>Thank you in advance,</p>