I am trying to make a simple url shortening service. I've two domains, one is parked (x.co) another is main (maindomain.com) domain. I want to make a redirection for parked domain in htaccess like this:
http://x.co/abc
will be redirected to:
http://maindomain.com/redirect.php?code=abc
I've tried a lot of different rules but none of them worked. For example, I've tried this:
RewriteCond %{HTTP_HOST} ^x.co$ [NC]
RewriteRule ^(.*)$ http://maindomain.com/redirect.php?code=$1 [R=301,L]
So, can anyone help me? Thanks...
Try this rule in document root of x.co
:
RewriteCond %{HTTP_HOST} ^x\.co$ [NC]
RewriteRule ^ http://maindomain.com/redirect.php?code=%{REQUEST_URI} [R=301,L,NE]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.