Home > Software design >  How can I redirect several different files to an url using .htaccess?
How can I redirect several different files to an url using .htaccess?

Time:09-19

I want to edit .htaccess placing the lines below into a single line:

Redirect 301 "/smartphone" "/roster.php"
Redirect 301 "/mobile" "/roster.php"

How can I do that?

CodePudding user response:

The corresponding RedirectMatch directive allows you to use a regex. For example:

RedirectMatch 301 ^/(smartphone|mobile) /roster.php

Reference:

  • Related