# mod_rewrite: Remove a query string parameter


# a2enmod rewrite
# service apache2 restart
# cat /etc/apache2/sites-available/default
        <Directory /var/www/>
                Options FollowSymLinks MultiViews
                AllowOverride All

# cat /var/www/.htaccess
RewriteEngine on
RewriteCond %{QUERY_STRING} ^(.*)[Pp][Aa][Rr][Aa][Mm]3=(.*?)(&(.*))?$
RewriteRule (.*) /$1?%1%4 [R=307]
>>> http://localhost/page.php?param1=1&param2=2&param3=3&param4=4&param5=5
<<< http://localhost/page.php?param1=1&param2=2&param4=4&param5=5

>>> http://localhost/page.php?param1=1&param3=3&param2=2&param3=3&param5=5
<<< http://localhost/page.php?param1=1&param2=2&param5=5

>>> http://localhost/page.php?param1=1&param2=2&PaRaM3=3
<<< http://localhost/page.php?param1=1&param2=2

No comments: