[SOLVED] Redirect all files in a folder
6 posts
• Page 1 of 1
[SOLVED] Redirect all files in a folder
Hi,
Quick question about using a map-file in Helicon Ape.
My .htaccess:
My map.txt so far:
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
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.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Redirect all files using a map-file in Helicon Ape possi
Hello,
If I'd need to wildcard the whole folder, I'd try the following additional rule with mapfile:
where newMap is:
p.s. OR you may keep existing mapfile and have sufficient entries for oldFolder and NewFolder
Regards
Andrew
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
Re: Redirect all files using a map-file in Helicon Ape possi
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
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
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Redirect all files using a map-file in Helicon Ape possi
Helllo,
than try using the following:
Regards
Andrew
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
- warriorfullights
- Posts: 19
- Joined: 28 Sep 2012, 01:54
Re: [SOLVED] Redirect all files in a folder
It worked. Thanks a lot.
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 25 guests