Rajender Kumar
Rajender Kumar

Reputation: 166

Redirect if URL match defined strings using .htaccess

I want to redirect a if URL match defined strings using .htaccess in a single line code

If URL is

Redirect URL

I tried this but i want to define string (e.g. books, mobiles, books) instead of (.*)

 RewriteRule ^(.*)/xyz/?$    upcoming/index.html    [NC,L]

Upvotes: 1

Views: 117

Answers (1)

Simone Torrisi
Simone Torrisi

Reputation: 101

Don't know if i've understand correctly the question, but this should do the trick:

 RewriteRule ^mobiles|books|computers/xyz/?$ upcoming/index.html [NC,L]

Tested on https://regex101.com/

Upvotes: 2

Related Questions