Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect on the basis of referer HTTP_REFERER htaccess

I've an issue where i want to redirect a user on the basis of a substring from referered url, How i can accomplish that using htaccess?

  1. User is on http://example.com/aqeel/videos/
  2. There is a hyperlink on the above page http://demo.example.com/
  3. When user reaches http://demo.example.com/, I want him to be redirected to http://demo.example.com/login/aqeel/, Here aqeel is the substring captured from the referer url in htaccess from step 1 URL.

Thanks in Advance,

like image 554
Aqeel Ahmad Avatar asked Mar 01 '11 06:03

Aqeel Ahmad


1 Answers

You can use below code to make that work:

RewriteCond %{HTTP_REFERER} http\:\/\/example.com/([a-z]+)/videos/
RewriteRule (.*)$ /login/%1/

I tried on my domain.. and it works... hope that too work with you... :)

like image 105
Love Sharma Avatar answered Oct 17 '22 10:10

Love Sharma