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
    Aug 2010
    Posts
    57
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Basic Redirect Writing

    This is a basic question about writing .htaccess Redirect.

    I want to redirect a call to a directory to a sub-directory within that directory.

    In my root directory’s .htaccess file, this works:

    Code:
    Redirect 301 /index.html /foldername/
    But I can’t get this to work in any other directory. I’ve tried many variations, such as --

    Code:
    Redirect 301 /foldername/index.html /foldername/subfolder/
    Redirect 301 index.html /subfolder/
    -- without result, so I’m wondering if I have some basic confusion about how this works.

    Thank you.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Code:
    Redirect 301 foldername/(.*) /foldername/subfolder/$1
    ?
    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
    Aug 2010
    Posts
    57
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Thank you.

    I'm still not getting it to work. Does that line of code go into an .htaccess within the "foldername" directory, or in the root directory's .htaccess, or ...?

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    The "Redirect" directive doesn't support patterns. You need to use "Rewrite" or "RedirectMatch".


  •  

    Posting Permissions

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