Forum Moderators: phranque

Message Too Old, No Replies

Folder Mass Redirection

Are these three rules correct?

         

omoutop

1:17 pm on Jan 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi to all!

I need to redirect three folders located to the root of my website, these are named: pelio, halkidiki and athens. All three folder contain numerous sub-folders and hunderds of files so wht I need is a mass 301,L redirection, is this feasible? Can it be done by using the rules below?

RewriteRule ^/athens $http://www.mysite.com/attica/athens [R=301,L]
RewriteRule ^/pelion $http://www.mysite.com/thessaly/pelion [R=301,L]
RewriteRule ^/halkidiki $http://www.mysite.com/macedonia/halkidiki [R=301,L]

Would these rules above include all sub-folders and files thus delivering a mass redirection?Is there a better way?

Thx in advance!

jdMorgan

2:18 am on Jan 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to create and use a back-reference to the (optional) path following the directory-name:

RewriteRule ^/athens[b](.*)[/b] $http://www.mysite.com/attica/athens[b]$1[/b] [R=301,L]
RewriteRule ^/pelion(.*) $http://www.mysite.com/thessaly/pelion$1 [R=301,L]
RewriteRule ^/halkidiki(.*) $http://www.mysite.com/macedonia/halkidiki$1 [R=301,L]

See the mod_rewrite documentation cited in our forum charter [webmasterworld.com].

If this code is for use in .htaccess instead of httpd.conf, omit the leading slash on the patterns. That is, use "^athens" instead of "^/athens", for example.

Jim

omoutop

5:56 am on Jan 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



thx very much jdmorgan!

I have already seen the mod_rewite documentation and from there I found the way to create these rules. Since they will be used in htaccess and not httpd.conf as you mention they will be :

RewriteRule ^athens(.*) $http://www.mysite.com/attica/athens$1 [R=301,L]
RewriteRule ^pelion(.*) $http://www.mysite.com/thessaly/pelion$1 [R=301,L]
RewriteRule ^halkidiki(.*) $http://www.mysite.com/macedonia/halkidiki$1 [R=301,L]

Thx again, my only matter was if these rules would be fine for the rest of folders and subfolders that apply after the $1 i.e. (athens/images/acropole/image1.jpg), now I know that it will work for all folders and subfolders!Thx again!