title: htaccess and custom php cms pretty urls
body: <p>I have built a custom PHP, mySQL CMS. The news article links show as this:</p>
  
  <p><a href="https://www.example.com/news/post.php/?p=example-article-slug" rel="nofollow noreferrer">https://www.example.com/news/post.php/?p=example-article-slug</a></p>
  
  <p>However, i want them to show as this:</p>
  
  <p><a href="https://www.example.com/example-article-slug" rel="nofollow noreferrer">https://www.example.com/example-article-slug</a></p>
  
  <p>The below code in the htacess file works but breaks all the other functionality in the htaccess such as the 404 and 301 redirects. Any ideas?</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ news/post.php/?p=$1 [QSA,L]
  </code></pre>
  
  <p>Here's my full htaccess ...</p>
  
  <pre><code>            RewriteEngine On 
              RewriteCond %{SERVER_PORT} 80 
              RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
  
              Options -Indexes
              ErrorDocument 201 /404.php
              ErrorDocument 401 /404.php
              ErrorDocument 404 /404.php
              ErrorDocument 402 /404.php
              ErrorDocument 505 /404.php
              ErrorDocument 500 /404.php
              RewriteEngine On
              RewriteBase /
  
              Redirect 301 /oldpage.php   http://www.example.com/
  
              #Check for www
              RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
              RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
  
              RewriteCond %{THE_REQUEST} \ /(.*/|)(?:index\.php)?\?id=([^\s&amp;]+) [NC]
              RewriteRule ^ /%1%2? [R=301,L,NE]
  
              RewriteEngine On
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteRule ^(.*)$ news/post.php/?p=$1 [QSA,L]
  
              RewriteEngine On
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteRule ^(.*)$ news/category/?cat=$1 [QSA,L]
  </code></pre>