Saturday, July 11, 2015

apache 2.2 - Rewriting main domain to subdomain (mod_rewrite)

So I'm trying to write a mod_rewrite rule that will send everything on my main domain to a subdomain.



For example, redirect



http://example.com/1/2/3/4/5?n=6&i=7


to



http://sub.example.com/1/2/3/4/5?n=6&i=7



Here's what I have so far:



RewriteEngine On
RewriteCond ^http://www\.example.com\/ [NC]
RewriteRule ^(.*)$ http://sub.example.com/$1 [R=301,L]


But it doesn't seem to working. Any tips?

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...