toolman Posted April 4, 2013 Share Posted April 4, 2013 Hi, I want to redirect a folder and also a folder within a folder to my homepage. Will the following redirect work? RewriteRule ^images/(.*) http://www.website.com [R=301,L] RewriteRule ^images/subfolder(.*) http://www.website.com [R=301,L] Thanks Quote Link to comment https://forums.phpfreaks.com/topic/276521-folder-redirect-question/ Share on other sites More sharing options...
requinix Posted April 4, 2013 Share Posted April 4, 2013 The second one is pointless because the first one will include the subfolder. That will redirect everything that tries to go to images/* to the homepage. If you have an image in there then it will not work. Is that what you want? Quote Link to comment https://forums.phpfreaks.com/topic/276521-folder-redirect-question/#findComment-1422930 Share on other sites More sharing options...
toolman Posted April 5, 2013 Author Share Posted April 5, 2013 Thanks for the reply. I want to redirect anyone trying to access the /images folder and also one specific folder within /images. There are other folders in there, but they could still be accessed. Is that possible? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/276521-folder-redirect-question/#findComment-1423021 Share on other sites More sharing options...
requinix Posted April 5, 2013 Share Posted April 5, 2013 Inside /images/.htaccess try RewriteRule ^/?$ / [L,R=301] RewriteRule ^/?subfolder(/|$) / [L,R=301] Quote Link to comment https://forums.phpfreaks.com/topic/276521-folder-redirect-question/#findComment-1423024 Share on other sites More sharing options...
toolman Posted April 5, 2013 Author Share Posted April 5, 2013 Thanks, would that be the only code i would need to put in the file - just two lines? Quote Link to comment https://forums.phpfreaks.com/topic/276521-folder-redirect-question/#findComment-1423027 Share on other sites More sharing options...
toolman Posted April 5, 2013 Author Share Posted April 5, 2013 I now have this, but it displays a forbiddon error: <Files .htaccess>order allow,denydeny from all</Files>RewriteEngine onRewriteRule ^/?$ / [L,R=301]RewriteRule ^/?subdirectory(/|$) / [L,R=301] Quote Link to comment https://forums.phpfreaks.com/topic/276521-folder-redirect-question/#findComment-1423029 Share on other sites More sharing options...
Solution toolman Posted April 5, 2013 Author Solution Share Posted April 5, 2013 Actually, it does work many thanks Quote Link to comment https://forums.phpfreaks.com/topic/276521-folder-redirect-question/#findComment-1423031 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.