i need a Solution for the google search console error links and RedirectMatch 301 remove query string / URL Parameters in my htaccess:
Google Search Console Links:
https://www.domain.de/?main_page=index&zenid=umf5etlrmr4blnuiq0e4jsp6l2&cPath=15_326&sort=20a&alpha_filter_id=68
https://www.domain.de/index.php?main_page=product_reviews_write&products_id=9985&cPath=5_380&number_of_uploads=0
https://www.domain.de/?main_page=index&cPath=46_47&sort=20a&alpha_filter_id=70
https://www.domain.de/?currency=USD&main_page=products_new&disp_order=7&page=141
https://www.domain.de/?main_page=index&zenid=mj6nsb9r53goiu6e13nb80tfq7&cPath=1_160&sort=20a&alpha_filter_id=70
https://www.domain.de/?currency=USD&main_page=index&cPath=3_137
https://www.domain.de/?main_page=index&cPath=46_76&sort=20a&alpha_filter_id=84
https://www.domain.de/?main_page=index&cPath=5_6&sort=20a&alpha_filter_id=85
https://www.domain.de/index.php?main_page=index
And many more.
I test this way in the htaccess, but it didn’t work:
RedirectMatch 301 ^/?main_page*$ https://www.domain.de/
RedirectMatch 301 ^/?main_page=$ https://www.domain.de/
RewriteEngine on
RewriteCond %{QUERY_STRING} ^main_page$ [NC]
RewriteRule ^/?main_page?$ https://www.domain.de/ [L,R=301]
2
Answers
You can use the following generic rule to remove query strings
Adding one more approach of htaccess rules here, written as per shown samples. Using Apache’s
THE_REQUEST
variable here.Make sure to clear your browser cache before testing your URLs.
OR as an alternative use following code(using
QSD
flag here to remove query string):