Search code examples
apache.htaccessyourls

Complex redirect with Apache


How I can redirect

  • osite.com
  • en.osite.com
  • ru.osite.com/product/1

and other different subdomains respectively to

  • so.kr/index.php?url=site.com
  • so.kr/index.php?url=en.site.com
  • so.kr/index.php?url=ru.site.com/product/1

in Apache? This is need for convenient links shortening of site.com. Thank in advance.


Solution

  • I don't understand it, but it work.

    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} ^([\w\d]+)\.osite\.ru$
    RewriteRule ^(.*)$ http://so.kr/index.php?url=http://%1.site.ru$1 [NC,L,QSA]