What are the potential pitfalls of trying to rewrite URLs with parameters in PHP for consistent link structure?

When rewriting URLs with parameters in PHP for consistent link structure, potential pitfalls include creating duplicate content issues, causing SEO problems, and breaking existing links that are indexed by search engines. To solve this, it is important to use proper redirection techniques, such as 301 redirects, to ensure that old URLs with parameters are redirected to the new clean URLs.

// Redirect old URLs with parameters to new clean URLs using 301 redirect
if(isset($_GET['parameter'])) {
    $new_url = "http://www.example.com/new-clean-url";
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: $new_url");
    exit();
}