Redirecting a directory and all the files in that directory

Discussion in 'Apache' started by Colbyt, Apr 6, 2008.

  1. #1
    Guys I really did search these forums and Google. The answer in a format that I could understand was not there. :)

    I am changing a script and the directory that it is in. Actually move it from a folder to the site root.There are some 2400 pages indexed. There aren't that many pages but WTH.

    How can I redirect an entire directory and all the pages that might be in it to a single page (the index page of the public_html folder). I do not want to use ErrorDoc to do this if I can avoid that.
     
    Colbyt, Apr 6, 2008 IP
  2. SSANZ

    SSANZ Peon

    Messages:
    861
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Put a index.php into the old folder and include the new index.php at the new URL.

    If you can use google, you can find out how ;)

    google - php function include

    If it doesn't work try a simple get in the header.
     
    SSANZ, Apr 6, 2008 IP
  3. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #3
    Problem is resolved.

    I am going to post a follow-up message to this post because as I continued to search I noticed in was near the top of the google results and other may be looking for the same answer. Several of the other results lead to these forums with no answers provided.

    I created this redirect using cPanel10 from the control panel. cPanel wrote something wierd to the .htaccess, which I wish I had copied before I changed it.



    Once I manually changed the syntax in the .htaccess file to:





    Everything worked as it should. Both the directory and any file that is called in that directory are now forwarded as desired.



    Having used cPanel many times to set redirects I really can not explain why this happened.
     
    Colbyt, Apr 10, 2008 IP