View Full Version : Redirection Without Keeping File Name?

08-19-2010, 12:43 AM
Is there any way to redirect all traffic from a folder to another web site WITHOUT keeping the name of any file inside of the folder?

For example, if I put the code below in folder /demo/

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule (.*) http://google.com/$1 [R=301,L]

then it only works if someone goes to folder /demo/. But if someone goes to a file inside of that folder (like index.php), then the name of the file they want to see (in this case index.php) gets attached to the end of the destination URL.

So they end up at, www.google.com/index.php

I want to strip all file names and just send people to www.google.com

Is there any way to do this??? :confused:

08-19-2010, 08:09 AM
If you just need to redirect "any" request under that folder to a "fixed" target, then you could omit that $1 at the end.
RewriteRule (.*) http://google.com/? [R=301,L]

08-19-2010, 12:39 PM
Thanx! That did it. :thumbsup:

How can I make it case insensitive? Sometimes people capitalize the letters in the
directory name, like /Demo/ and it doesn't redirect.

09-11-2010, 04:09 AM
RewriteRule (.*) http://google.com/? [R=301,L,NC]

Try that.