Search code examples
.htaccesshttp-redirectmod-rewriteurl-rewriting

Redirect and rewrite my URLs with an .htaccess file?


Redirect and rewrite my URLs with an .htaccess file?

Duplicate content, 2 links with the same content.

https://www.pooeen.com/viewtopic.php?f=3&t=30

Please be redirected to the URL below

https://www.pooeen.com/viewtopic.php?t=30

I am looking forward to hearing from you soon.

Thank you in advance for invaluable co-operation.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|html)\ HTTP
RewriteRule ^(.*)index\.(php|html)$ /$1 [R=301,L]
</IfModule>

Solution

  • With your shown samples please try following .htaccess rules.

    RewriteEngine ON
    
    ##Using THE_REQUEST for catching references and using them later on.
    RewriteCond %{THE_REQUEST} \s/(viewtopic\.php)\?f=(?:[^&]*)&(t=\d+)\s [NC]
    RewriteRule ^ /%1?%2 [R=301,L]