Search code examples
.htaccesshttp-redirecthttp-status-code-404dynamic-url

Redirect 301 dynamic-URL to 404 error-page with htaccess?


Can someone help me to get the correct .htaccess rules for:

Redirect this specific ID url:

http://www.domain.com/watch.php?id=00000000001

to my 404 error page:

http://www.domain.com/404/

Solution

  • Use this rule in your DOCUMENT_ROOT/.htaccess file:

    RewriteEngine On
    
    RewriteCond %{QUERY_STRING} ^id=00000000001$ [NC]
    RewriteRule ^watch\.php$ /404/? [NC,L,R=301]