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. Link to comment https://forums.phpfreaks.com/topic/135274-forward-all-subfoldersfiles-to-the-root/ 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/ Link to comment https://forums.phpfreaks.com/topic/135274-forward-all-subfoldersfiles-to-the-root/#findComment-704573 Share on other sites More sharing options...
tuckker Posted December 3, 2008 Author Share Posted December 3, 2008 Does this work in Tomcat? Link to comment https://forums.phpfreaks.com/topic/135274-forward-all-subfoldersfiles-to-the-root/#findComment-704585 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. Link to comment https://forums.phpfreaks.com/topic/135274-forward-all-subfoldersfiles-to-the-root/#findComment-704589 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? Link to comment https://forums.phpfreaks.com/topic/135274-forward-all-subfoldersfiles-to-the-root/#findComment-704612 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 Link to comment https://forums.phpfreaks.com/topic/135274-forward-all-subfoldersfiles-to-the-root/#findComment-704616 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.