-2

How to create redirect from site.ru/idxxxxx to site.ru/name.php?id=xxxxx

I can create redirect using .htaccess . But how to get an id from first link /idXXXXX and put into second ?id=XXXXX using .htaccess?

nikamon
  • 29
  • 5

1 Answers1

1

Try this rewrite rule in your htaccess

RewriteRule ^id(.*)$ name.php?id=$1 [L,QSA]

This will match any characters after id

if you want to match it if only digits exists after id

RewriteRule ^id([0-9]+)$ name.php?id=$1 [L,QSA]

[0-9]+ regular expression satisfies for any length of digits

.* matches matches any length of characters except newline.

Manpreet
  • 1,860
  • 13
  • 18