Siraj ul Haq
Siraj ul Haq

Reputation: 885

Redirect url other then root to subdomain

I want to do following redirects:

http://example.com to some static page
http://exmaple.com/<anything> to http://subdomain.example.com/<anything>

Currently i have this:

RewriteRule ^/?$ static/index.html [L]
RewriteRule ^(*)?$ http://sub.example.com/$1 [L]  

Any help is appreciated. Thanks

Upvotes: 0

Views: 52

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

You can try these rules :

RewriteEngine on

#1)This will redirect the homepage of example.com to /static/index.html#
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^$ /static/index.html [NC,L]
#2)This will redirect  /anything  to sub.example.com#
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteCond %{REQUEST_URI} !^/static/index\.html [NC]
RewriteRule ^(.+)$ http://sub.example.com/$1 [NC,L,R,NE]

Upvotes: 1

Related Questions