title: Vanity Profile url using htaccess with PHP
body: <p>I have <code>.htaccess</code> file, <code>profile.php</code>, <code>index.php</code> and <code>test.php</code>.</p>
  
  <p>Let's say we have user <code>john</code></p>
  
  <p>If I will go to website <code>http://example.org/john</code>, then I can see <code>john</code> profile.
  But If I will go to <code>index.php</code> or <code>test.php</code>, then pages are with error 404 but shouldn't be. It seems that code from htaccess file is crashing every page.</p>
  
  <p>How I can fix <code>profile.php</code> and <code>.htaccess</code> file to get:</p>
  
  <ol>
  <li>If <code>http://example.org/john</code> doesn't exist, then show 404 error on the same page, if exist - show this profile</li>
  <li>Other pages should display if they exist (like <code>test.php</code>)</li>
  </ol>
  
  <p>Code:</p>
  
  <p><strong>.htaccess</strong></p>
  
  <pre><code>Options +FollowSymLinks
  RewriteEngine On
  RewriteBase /
  DirectorySlash Off
  
  
  RewriteRule ^([A-Za-z0-9\._\-]+)[^.]$ profile.php?user=$1 [NC]
  
  
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteRule ^(.*?)/?$ /$1.php [NC,END]
  </code></pre>
  
  <p><strong>profile.php</strong></p>
  
  <pre><code>&lt;?php
  if ($_GET['user'] != '') {
  
      echo 'Showing user profile';
  
  } else {
  
      echo '404 error';
  
  }
  </code></pre>