title: How to Remove Slug from my Post , Post.php?Slug=postname-title
body: <p>I have made a blog in PHP, on Post.php with If isset get I am checking Post ID and than getting slug of same ID from database and accessing the post with that slug.</p>
  <p>The issue is its generating Url like: Post.php?Slug=postname-title
  I want to make it Post.php?postname-title OR urls.com/postname-title</p>
  <p>Please note I am getting post from database matching with slug If any how I do not set php to Get in url it is not getting value from the same slug.</p>
  <p>Please guide if it will be done via .htaccess or any other way?</p>
  <pre><code> &lt;?php
              // add mysql_real_escape_string to slug, to prevent sql injection
              $slug = $_GET[&quot;slug&quot;];
              $sql = &quot;SELECT * FROM posts WHERE slug = '&quot; . mysqli_real_escape_string($db, $_GET[&quot;slug&quot;]) . &quot;'&quot;;
              $result = mysqli_query($db, $sql);
              if (mysqli_num_rows($result) &gt; 0) {
                  // output data of each row
                  while ($row = mysqli_fetch_assoc($result)) {
                      echo &quot;&lt;h2&gt;&quot; . $row[&quot;title&quot;] . &quot;&lt;/h2&gt;&quot;;
                      echo &quot;&lt;div id='post-details'&gt;&quot; . &quot;Posted on &quot; .  $row[&quot;post_date&quot;] . &quot;  --  &quot; . &quot;Last Update &quot; .  $row[&quot;last_edited&quot;]  .
                          &quot;&lt;/div&gt;&quot;;
                          
                          if (loggedin()) {  echo &quot;&lt;div id='postactions'&gt;This Post:&lt;a href='create_note.php?id=&quot; . $row[&quot;id&quot;] . &quot;'&gt;Add Notes&lt;/a&gt;&quot;;
                              echo '&lt;a href=&quot;delete_post.php?id=' . $row[&quot;id&quot;] . '&quot; onclick=&quot;return confirm(\'Are you sure you want to delete this post?\')&quot;&gt;Delete Post&lt;/a&gt;';
                              echo '&lt;a href=&quot;edit_post.php?id=' . $row[&quot;id&quot;] . '&quot;&gt;Edit&lt;/a&gt;&lt;/div&gt;'; } 
  
   
                      $cat_id = $row[&quot;cat_id&quot;];
                      $sql = &quot;SELECT * FROM categories WHERE id = $cat_id&quot;;
                      $resultone = mysqli_query($db, $sql);
                      if (mysqli_num_rows($resultone) &gt; 0) {
                          // output data of each row
                          while ($rowone = mysqli_fetch_assoc($resultone)) {
                              $cat_name = $rowone[&quot;name&quot;];
                              echo &quot;&lt;div id='post-category'&gt;&quot; . &quot;Category: &lt;a href='all-categories.php?cat_id=$cat_id'&gt;$cat_name&lt;/a&gt;&quot; . &quot;&lt;/div&gt;&quot;;
                          }
                      }
  
  
  
              echo &quot;&lt;p&gt;&quot; . htmlspecialchars_decode($row[&quot;body&quot;]) . &quot;&lt;/p&gt;&quot;;
            
              $_SESSION[&quot;post_id&quot;] = $row[&quot;id&quot;];
                      $postid =  $row[&quot;id&quot;];
                  }
              } else {
                  echo &quot;0 results&quot;;
              }
  
              ?&gt;
  </code></pre>