Mod-rewrite or other to redirect folders


I want to change URL's but not my folder structures.

I have:
.... 10000 times

Is there away in Apache that I can redirect to but keep the folder paths.

So if someone goes to they will be redirected to

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.

Who is Participating?
arober11Connect With a Mentor Commented:
The following in your httpd.conf or .htaccess should do:

RewriteEngin On
RewriteCond %{REQUEST_URI} !^[/]*$
RewriteRule ^.*{REQUEST_URI} [L,R=301]

Note: If the two domain's are hosted by the same apache instance, you need to add back the following line:

RewriteCond %{HTTP_HOST}    ^www\.example\.com [NC]
Using the example from the Apache URL Re-write page modified just a bit

RewriteCond %{HTTP_HOST}   ^www\.example\.com [NC]
RewriteRule ^/(.*)$1 [L,R]
brittonvAuthor Commented:
would this allow me to host a page as well?

Meaning goes to an actual index.html page while* goes to the*
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

No it would not, it would redirect all requests for to

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* redirected to* ?

Or are there other patterns?
brittonvAuthor Commented:
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 I want to display a message that they this domain is no longer valid and have them redirect to another URL.  SO would redirect to

While if someone goes to, 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

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.

What arober11 provide will do what you want.
brittonvAuthor Commented:
Can I just put this within a <VirtualHost> tag?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.