Shijin T R Shijin T R - 1 year ago 90
Apache Configuration Question

Apache redirect sub domain to main domain conditionally

I have one domain and a sub domain like and

I need to redirect all to with the following condition. to<any url> to<any url>

I have added the bellow code in my apache config file of

Redirect 301 /

Now successfully redirecting to but all other pages are not working .That are redirecting to

How to solve this issue?

Answer Source

The best way is to use rewrite rules.

RewriteRule ^/$ [R]
RewriteRule ^/(.+)$1 [R]

Dont forget to add the module and enable the RewriteEngine

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download