tuckker Posted December 3, 2008 Share Posted December 3, 2008 How do I redirect all subfolders/files to the root of the link domain.com? Eg: When user opens www.domain.com/abc, i want Apache (Tomcat to be exact) to redirectthe user to www.domain.com. This goes the same for www.domain.com/abc/abc or www.domain.com/abc/abc.html etc... Thanks. Quote Link to comment Share on other sites More sharing options...
dclamp Posted December 3, 2008 Share Posted December 3, 2008 You need to create a .htaccess file and put the following in it. It will redirect all to the location you specify. RedirectMatch permanent ^/$ http://mydomain.com/ Quote Link to comment Share on other sites More sharing options...
tuckker Posted December 3, 2008 Author Share Posted December 3, 2008 Does this work in Tomcat? Quote Link to comment Share on other sites More sharing options...
dclamp Posted December 3, 2008 Share Posted December 3, 2008 as long as you have apache it should work. Quote Link to comment Share on other sites More sharing options...
tuckker Posted December 3, 2008 Author Share Posted December 3, 2008 I used the code you suggested, and the outcome was: accessing domain.com will redirect perfectly fine. But accessing domain.com/abc will gives me 404 error... If I change it to: redirectMatch permanent ^(/.+)?/?$ http://domain.com/index.htm Then it will keep entering a loop... any idea? Also, how do I add an exclusion to a folder? Quote Link to comment Share on other sites More sharing options...
dclamp Posted December 3, 2008 Share Posted December 3, 2008 hmm. have a look here, maybe it will help. http://www.webmasterworld.com/apache/3180546.htm Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.