title: RewriteRule to redirect example.com/12345 to https://example.com/index.html?id=12345
body: <p>I am trying to create a way for users to type the url as example.com/12345 and rewrite it as <a href="https://www.example.com/index.html?id=12345" rel="nofollow noreferrer">https://www.example.com/index.html?id=12345</a>.  The "id" parameter should be a minimum of 6 digits and should have no maximum.  I don't seem to be able to get the first RewriteRule to work correctly.  When a user keys the url like <code>www.example.com/12345</code>, it redirects to <code>https://www./12345</code>.</p>
  
  <p>The second RewriteRule is redirecting all other traffic to <a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a> without issues.</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      &lt;Directory /var/www/vhosts/example/public&gt;
          Options Indexes FollowSymLinks
          AllowOverride All
          Require all granted
      &lt;/Directory&gt;
  
      ServerAdmin admin@example.com
      ServerName example.com
      ServerAlias www.example.com
      DocumentRoot /var/www/vhosts/example/public
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
      RewriteEngine On
      RewriteCond %{HTTPS} off [OR]
      RewriteCond %{HTTP_HOST} !^www\. [NC]
      RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
      RewriteRule ^([0-9]{6,})$ https://www.example.com/index.html?id=$1 
          [QSA,L,R=301,NE]
      RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
  &lt;/VirtualHost&gt;
  </code></pre>