Q:

301 redirect to the rewrited url

The CMS i am working with has these rewrite rules:
For the tags:
RewriteRule ^tags/([^/]+)/$ tag.php?t=$1&page=1
RewriteRule ^tags/([^/]+)/page-([0-9]+)(/)?$ tag.php?t=$1&page=$2

for the category pages:
RewriteRule ^browse-(.*)-videos.html$ category.php?cat=$1
RewriteRule ^browse-(.*)-videos-([0-9]+)-(.*).html$ category.php?cat=$1&page=$2&sortby=$3

But it does not redirect to the seo friendly url estructure creating duplicate content issues, how can i make so it also 301 redirects to the rewrited url if accessed from the other?
Thanks in advance

A:

You need to create 4 new rules and place them above your existing.
#redirect old URL to new SEO
RewriteCond %{THE_REQUEST} ^GET\ /+tag\.php\?t=([^&\s]+)&page=1
RewriteRule ^ /tags/%1/? [R=301,L]
#redirect old URL to new SEO
RewriteCond %{THE_REQUEST} ^GET\ /+tag\.php\?t=([^&\s]+)&page=([^&\s]+)
RewriteRule ^ /tags/%1/page-%2/? [R=301,L]
#redirect old URL to new SEO
RewriteCond %{THE_REQUEST} ^GET\ /+category\.php\?cat=([^&\s]+)&page=([^&\s]+)&sortby=([^&\s]+)
RewriteRule ^ /browse-%1-videos-%2-%3.html? [R=301,L]
#redirect old URL to new SEO
RewriteCond %{THE_REQUEST} ^GET\ /+category\.php\?cat=([^&\s]+)
RewriteRule ^ /browse-%1-videos.html? [R=301,L]

RewriteRule ^tags/([^/]+)/$ tag.php?t=$1&page=1 [L]
RewriteRule ^tags/([^/]+)/page-([0-9]+)(/)?$ tag.php?t=$1&page=$2 [L]

RewriteRule ^browse-(.*)-videos.html$ category.php?cat=$1 [L]
RewriteRule ^browse-(.*)-videos-([0-9]+)-(.*).html$ category.php?cat=$1&page=$2&sortby=$3 [L]

