301 Redirect Entire Directory And Sub Dirs

liunx

Guest
Hi,<br /><br />I setup a 301 redirect for a directory that contained numerous subdirectories, (all got indexed by Google accidentally.)<br /><br />Here is an example of the code:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->redirect 301 /olddir http://www.****/index.php<!--c2--></div><!--ec2--><br /><br />However if I go to a link like this:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->http://www.****/olddir/album01/blahblah<!--c2--></div><!--ec2--><br /><br />It ends up going here:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->http://www.****/index.php/album01/blahblah<!--c2--></div><!--ec2--><br /><br />I don't know the names of all the subdirectories, there are hundreds too. So I was wondering if there is a way to include all subdirectories in 1 line of code.<br /><br />Thanks for any suggestions. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br /><br />oye, sorry about the URLs, i forgot those are probably not allowed... trying to turn them off... ok got it.<!--content-->
Do you have any other code in your .htaccess that is messing things up ?<!--content-->
Possibly... I have this line above it:<br />(my old site had an index.shtml page, but the new one is .php)<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->redirect 301 /index.shtml http://www.****.com/index.php<!--c2--></div><!--ec2--><br /><br />and this below it, for image protection and redirecting the non-www domain:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Options +FollowSymLinks <br />RewriteEngine On <br />RewriteCond %{HTTP_Host} ^****.com [NC] <br />RewriteRule ^(.*)$ http://www.****.com/$1 [L,R=301]<br />RewriteCond %{HTTP_REFERER} !^http://****.com/ [NC]<br />RewriteCond %{HTTP_REFERER} !^http://****.com [NC]<br />RewriteCond %{HTTP_REFERER} !^http://www.****.com/ [NC]<br />RewriteCond %{HTTP_REFERER} !^http://www.****.com [NC]<br />RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]<!--c2--></div><!--ec2--><br /><br />Sorry I shoulda posted this in the first place. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/wallbash.gif" style="vertical-align:middle" emoid=":wallbash:" border="0" alt="wallbash.gif" /><br /><br />(not sure if that bottom part is the most efficient way to redirect and image protect, i keep seeing many different ways and don't know what's best)<!--content-->
Try:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->redirectmatch 301 /olddir/.* http://www.****/index.php<!--c2--></div><!--ec2--><!--content-->
Thank you click, works perfectly now. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/notworthy.gif" style="vertical-align:middle" emoid=":notworthy:" border="0" alt="notworthy.gif" /><!--content-->
 
Top