Shijin T R Shijin T R - 8 months ago 54
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?


The best way is to use rewrite rules.

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

Dont forget to add the module and enable the RewriteEngine