Need to rewite question marks and equals signs in url

Question!

Rewritten my url. However I can still access rewritten urls with question marks and plus signs.

lovelakedistrict.com/lake-district-cottages/?cottages=2/
lovelakedistrict.com/lake-district-cottages/?cottages/2/
lovelakedistrict.com/lake-district-cottages/cottages/2/

The three urls above are the exact same page, I would like to properly re-write them so they redirect to the correct structure (the last url) to stop duplication of webpages.

Options +FollowSymlinks
Options +Indexes
RewriteEngine on

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^.#?\ ]+)\.php([#?][^\ ]*)?\ HTTP/

RewriteCond %1 !^include/
RewriteRule ^([^.]+)\.php$ /$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ $1.php

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

RewriteRule ^lake-district-cottages/cottages/([0-9]+) lake-district-cottages.php?cottages=$1
By : AJFMEDIA


Answers

Try these rules:

RewriteCond %{THE_REQUEST} ^[A-Z] \ /[^?\ ]*\?[^\ ] 
RewriteCond %{QUERY_STRING} ^/*([^=
By : Gumbo


This video can help you solving your question :)
By: admin