brittonv
asked on
Mod-rewrite or other to redirect folders
Greetings,
I want to change URL's but not my folder structures.
I have:
www.domain.com/folder1/folder2/file.exe
www.domain.com/folder3/folder24/secondfile.exe
.... 10000 times
Is there away in Apache that I can redirect www.domain.com to another.domain.com but keep the folder paths.
So if someone goes to www.domain.com/folder1/folder2/file.exe they will be redirected to another.domain.com/folder1 /folder2/f ile.exe?
I know how to do it with mod-rewrite on a folder by folder basis, but I don't' want to do it 1000's of times for every folder.
Thanks
I want to change URL's but not my folder structures.
I have:
www.domain.com/folder1/folder2/file.exe
www.domain.com/folder3/folder24/secondfile.exe
.... 10000 times
Is there away in Apache that I can redirect www.domain.com to another.domain.com but keep the folder paths.
So if someone goes to www.domain.com/folder1/folder2/file.exe they will be redirected to another.domain.com/folder1
I know how to do it with mod-rewrite on a folder by folder basis, but I don't' want to do it 1000's of times for every folder.
Thanks
ASKER
would this allow me to host a www.example.com page as well?
Meaning www.example.com goes to an actual index.html page while www.example.com/* goes to the another.example.com/*
Meaning www.example.com goes to an actual index.html page while www.example.com/* goes to the another.example.com/*
No it would not, it would redirect all requests for www.example.com to another.example.com.
If you want to redirect specify folders, you need to either list all as a condition, or come up with a regular expression that would catch what you want without catching things you don't want.
Do you just want www.example.com/folder2/* redirected to anotherhost.example.com/fo lder1/fold er2/* ?
Or are there other patterns?
If you want to redirect specify folders, you need to either list all as a condition, or come up with a regular expression that would catch what you want without catching things you don't want.
Do you just want www.example.com/folder2/* redirected to anotherhost.example.com/fo
Or are there other patterns?
ASKER
There are patterns.
I need /folder1/folder2/file.exe to match the same directory on the new server.
However if they go to the root www.example.com I want to display a message that they this domain is no longer valid and have them redirect to another URL. SO
www.example.com/folder1/folder2/file.exe would redirect to
fw.newdomain.com/folder1/f older2/fil e.exe
While if someone goes to www.example.com, they would see a message saying:
The website you are trying to reach is no longer valid, please wait while you are redirected or click here.
and then they would be sent to www.newdomain.com/newpage.html
I want people to still get their files if they access the old url, but at the same time people going to the home page should be redirected.
I need /folder1/folder2/file.exe to match the same directory on the new server.
However if they go to the root www.example.com I want to display a message that they this domain is no longer valid and have them redirect to another URL. SO
www.example.com/folder1/folder2/file.exe would redirect to
fw.newdomain.com/folder1/f
While if someone goes to www.example.com, they would see a message saying:
The website you are trying to reach is no longer valid, please wait while you are redirected or click here.
and then they would be sent to www.newdomain.com/newpage.html
I want people to still get their files if they access the old url, but at the same time people going to the home page should be redirected.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What arober11 provide will do what you want.
ASKER
Can I just put this within a <VirtualHost> tag?
Yes.
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^/(.*) http://another.example.com/$1 [L,R]
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html