0

I need help to create a code that redirects only users who came to my website from an url containing specific word, lets say for example "recipes". If the user comes to my website from a website that contains in the url the word recipes, then redirect to another another URL if not, nothing happens. The script must be using php or javascript but not htaccess rules.

Also I would appreciate if the redirection can use regular expression, for example mywebsite.com/post to website.net/post.

  • For which reason you wouldn't do that with a `.htaccess` file? typically this would be great and avoid having some PHP processing. Avoid doing that in JavaScript. – Patrick Janser Sep 24 '21 at 08:10
  • 1
    [Please search your title first](https://www.google.com/search?q=redirect+php+when+url+contains+site%3Astackoverflow.com) – mplungjan Sep 24 '21 at 08:12

0 Answers0