title: How to keep hash in redirect url Laravel 8 and Inertiajs
body: <p>I am using Laravel 8 with Inertiajs and React. I'm trying to redirect to a url with a hash on the end of the url, and for some reason no matter how I construct the url, Laravel is stripping the fragment at the end. Even when I explicitly use <code>withFragment</code>, it doesn't work. Here's my controller:</p>
  <pre class="lang-php prettyprint-override"><code>    /**
       * Handle request to store a new answer
       */
      public function store(Request $request)
      {
          $userId = Auth::id();
          $question = Question::find($request-&gt;input('question')['id']);
          $questionAuthor = User::find($question-&gt;user_id);
          $answer = $request-&gt;input('answer');
  
          $newAnswer = new Answer; 
          $newAnswer-&gt;body = $answer['body'];
          $newAnswer-&gt;user_id = $userId;
          $newAnswer-&gt;question_id = $question-&gt;id;
          $newAnswer-&gt;save();
  
          Mail::to($questionAuthor)-&gt;send(new NewAnswer(
              $questionAuthor, 
              $newAnswer,
              $question
          ));
  
          $url = url(&quot;/questions/{$question-&gt;slug}&quot;);
  
          return redirect($url)-&gt;withFragment($newAnswer-&gt;id);
      }
  </code></pre>
  <p>If someone could help me understand why the hash is being stripped from the end and how I might fix it, I would be very grateful. Thanks.</p>