Search code examples
.htaccesshttp-redirectmod-rewriteurl-rewriting

Redirect & 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?t=82

Please be redirected to the URL below

https://www.pooeen.com/82/

I am looking forward to hearing from you soon.

Thank you in advance for invaluable co-operation.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^176\.9\.11\.218
RewriteRule ^(.*)$ https://www.pooeen.com/$1 [R=301,L]
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^pooeen\.com [OR]
RewriteCond %{HTTP_HOST} ^176\.9\.11\.218 [OR]
RewriteCond %{HTTP_HOST} ^mail\.pooeen\.com
RewriteRule ^(.*)$ https://www.pooeen.com/$1 [R=301,L]
</IfModule>

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

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/(viewtopic\.php)\?f=(?:[^&]*)&(t=\d+)\s [NC]
RewriteRule ^ /%1?%2 [R=301,L]
</IfModule>

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>

<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>

<Files .htaccess>
order allow,deny
deny from all
</Files>

DirectoryIndex index.php

Options -Indexes

Solution

  • You can apply and try the below solution most probably it should work.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{THE_REQUEST} \s/viewtopic\.php\?t=(\d+)\s [NC]
    RewriteRule ^ /%1? [R=301,L]
    </IfModule>
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(\d+)$ /viewtopic.php?t=$1 [QSA,L]
    </IfModule>