How to prevent a rewriterule from changing the url to include a querystring when undesired?

I am having some trouble getting mod-rewrite rules in my .htaccess file to work like I need them to.

I am trying to translate web requests made from:

Read More

http://www.masterongspropshop.com/blog/22

To:

.../blog.php?idPost=22

When I try, the URL always reverts to .../blog?idPost=22. I have tried a couple of different variations but all of them seem to end with a similar result.

The rewrite rules currently look like this:

RewriteRule ^blog$ blog.php [L]
RewriteRule ^blog/([0-9]*)$ blog.php?idPost=$1 [L,QSA]

Related posts

Leave a Reply

1 comment

  1. Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

    Options +FollowSymLinks -MultiViews
    # Turn mod_rewrite on
    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^blog/([0-9]+)/?$ blog.php?idPost=$1 [L,QSA,NC]