Stop query string to be added to url

I have a rewrite rule for my site that passes everything after the domain name as a parameter:

RewriteRule ^([0-9a-zA-Z_=/&\-]+)?$ index.php?page=$1   [L,QSA]

      

But when going to:

mydomain.co.uk/mypage

      

.. it adds a query string after the url (in the browser's address bar) like this:

mydomain.co.uk/mypage?page=mypage

      

I thought it was just crunching, weird ... but it does it in IE too.

Has anyone ever had this? Any help would be great, I just need it to not add the query string all the way to the end and stay like "mydomain.co.uk/mypage"

+3


source to share


1 answer


You can use a condition to check if the requested file exists.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) index.php?page=$1   [L,QSA]

      



I checked this code with htaccess.mwl.be for this requested url http://mydomain.co.uk/mypage?page=mypage

and redirects it tohttp://mydomain.co.uk/index.php?page=mypage

0


source







All Articles