[SOLVED] Redirect all files in a folder

Helicon Ape provides support for Apache .htacces and .htpasswd configuration files for Microsoft IIS.
User avatar
Posts: 6
Joined: 12 Sep 2012, 12:40

[SOLVED] Redirect all files in a folder

18 Sep 2012, 14:01

Hi,

Quick question about using a map-file in Helicon Ape.

My .htaccess:
Code: Select all
RewriteEngine on
RewriteBase /
RewriteMap mapfile txt:map.txt

RewriteCond ${mapfile:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.+)$ http://www.domain.com/${mapfile:$1} [NC,R=301,L]


My map.txt so far:
Code: Select all
index.html      /
index.htm      /
old-folder/default.asp      new-folder/something-default.asp


Question: Is is possible to redirect everything from some non-existing, old folder using a map-file or should this be in the .htaccess file? How?
For example, when a visitor goes to http://www.domain.com/older-folder/test.html redirect him/her to http://www.domain.com/new-folder/something-default.asp

Thanks in advance.

Regards,
Frank
Last edited by FrankD on 24 Sep 2012, 11:52, edited 1 time in total.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect all files using a map-file in Helicon Ape possi

18 Sep 2012, 23:46

Hello,

If I'd need to wildcard the whole folder, I'd try the following additional rule with mapfile:

Code: Select all
RewriteMap newMap txt:Nmap.txt

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${newMap:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^older-folder/(.*)$ http://www.domain.com/new-folder/${newMap:$1} [NC,R=301,L]

where newMap is:

Code: Select all
test.asp somethingNew.html



p.s. OR you may keep existing mapfile and have sufficient entries for oldFolder and NewFolder

Regards
Andrew

User avatar
Posts: 6
Joined: 12 Sep 2012, 12:40

Re: Redirect all files using a map-file in Helicon Ape possi

19 Sep 2012, 05:30

Thanks for the quick reply. I've tested this and it works as long as I have the entry in the new map-file.

Sorry if I wasn't clear enough. What I'm looking for, and maybe this can be done without a map-file, is when a visitor goes to any file in the older-folder, 301 redirect him/her to http://www.domain.com/new-folder/somefile.asp every time. So whether the visitor goes to http://www.domain.com/older-folder/test.asp, http://domain.com/older-folder/blabla.htm, https://www.domain.com/older-folder/blibli.html etc. it should always 301 redirect to http://www.domain.com/new-folder/somefile.asp as long as /older-folder/ was used. non-www and https should redirect too if possible.

Many thanks,
Frank

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect all files using a map-file in Helicon Ape possi

19 Sep 2012, 08:39

Helllo,

than try using the following:

Code: Select all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^older-folder/.*$ http://www.domain.com/new-folder/somepage.asp [NC,R=301,L]


Regards
Andrew

User avatar
Posts: 6
Joined: 12 Sep 2012, 12:40

Re: Redirect all files using a map-file in Helicon Ape possi

19 Sep 2012, 10:41

Thanks Andrew. I'll try that!

Posts: 19
Joined: 28 Sep 2012, 01:54

Re: [SOLVED] Redirect all files in a folder

01 Oct 2012, 23:51

It worked. Thanks a lot. Image

Return to Helicon Ape

Who is online

Users browsing this forum: No registered users and 38 guests