Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2009
    Posts
    40
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question Redirection Without Keeping File Name?

    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???

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    If you just need to redirect "any" request under that folder to a "fixed" target, then you could omit that $1 at the end.
    Try
    Code:
    RewriteRule (.*) http://google.com/? [R=301,L]
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Oct 2009
    Posts
    40
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Redirection Without Keeping File Name?

    Thanx! That did it.

    How can I make it case insensitive? Sometimes people capitalize the letters in the
    directory name, like /Demo/ and it doesn't redirect.
    Last edited by Phred; 08-19-2010 at 01:39 PM.

  • #4
    New Coder
    Join Date
    Aug 2007
    Posts
    58
    Thanks
    2
    Thanked 6 Times in 6 Posts
    Code:
    RewriteRule (.*) http://google.com/? [R=301,L,NC]
    Try that.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •