Home > Enterprise >  How to 301 redirect urls with htaccess?
How to 301 redirect urls with htaccess?

Time:08-18

I dont know how is the right way to redirect this:

RewriteRule ^set-(.*)-top-(.*)$ kat.php?st=$1&znamime=$2
RewriteRule ^set-(.*)-(.*)-(.*)-(.*)$ kat.php?st=$1&sir=$2&vis=$3&pre=$4
RewriteRule ^set-(.*)-(.*)-(.*)$ kat.php?st=$1&ime=$2&col=$3
RewriteRule ^set-(.*)-(.*)$ kat.php?st=$1&ime=$2
RewriteRule ^set-(.*)$ kat.php?st=$1

This URLs look like this:

/set-cool-top-brand
/set-cool-25-8-12
/set-cool-big-19
/set-cool-small
/set-cool

The COOL is called in php. Now I will change it to BEST and I need help how to 301 redirect it right for all options?

Thank you

CodePudding user response:

I find the solution:

RewriteRule ^set-cool(.*)$ /set-best$1 [R=301,L]

Thank you!

CodePudding user response:

This probably is what you are looking for, considering your additional comment to the question:

RewriteEngine on
RewriteRule ^/?set-cool-top-(.*)$ kat.php?st=best&znamime=$1 [END]
RewriteRule ^/?set-cool-(.*)-(.*)-(.*)$ kat.php?st=best&sir=$1&vis=$2&pre=$3 [END]
RewriteRule ^/?set-cool-(.*)-(.*)$ kat.php?st=best&ime=$1&col=$2 [END]
RewriteRule ^/?set-cool-(.*)$ kat.php?st=best&ime=$1 [END]
RewriteRule ^/?set-cool$ kat.php?st=best [END]

It matches the literal string "set-cool" and fills in the fixed and literal string "best" as "st" GET argument.

  • Related