title: What does it mean ^([a-zA-Z0-9_-]+)$ profile.php?u=$1 an it ^([a-zA-Z0-9_-]+)/$ profile.php?u=$1?
body: <p>At the moment I am developing a website with user interaction. I could transform all of the usernames in links for the profile page with a file .htaccess that has the following commands:</p>
  
  <pre><code>RewriteEngine on
  RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?u=$1
  RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?u=$1
  </code></pre>
  
  <p>If I understand correctly, this code substitutes the "profile.php" for the argument after the signal "?" if the URL matches the regular expression. But I didn't understood how the "u=$1" accomplishes that because the "u" is not a variable session. This is my configuration in PHP for the session variables:</p>
  
  <pre><code>$_SESSION["id"] = $id;
  $_SESSION["username"] = $username;
  $_SESSION["password"] = $pswd;
  $_SESSION["email"] = $email;
  </code></pre>
  
  <p>I would like to include too space in the regular expression, because at the moment only usernames like "FirstUser" are accepted, user names like "First User" give me an error at the browser.</p>
  
  <p>When I add a space in the pattern I get the following HTTP 500 error:</p>
  
  <p><img src="https://i.stack.imgur.com/upHxd.png" alt="Server Error"></p>