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 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2009
    Posts
    61
    Thanks
    15
    Thanked 0 Times in 0 Posts

    .htaccess redirect a folder within a folder

    Hi All,

    I have a folder within a folder that needs redirecting, for example:

    http://www.domain.com/directory/folder1 which needs re-directing to http://www.domain.com/directory/folder2 and have been using the following code:

    Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^(.*)/folder1/(.*)$ $1/folder2/$2 [R,L]
    However this is re-directing to http://www.domain.com/var/www/vhosts...ctory/folder2/

    Any ideas how to fix this?

  • #2
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    people love rewrite these days...

    if you want redirect http://example.com/testdir/dir1/ to http://example.com/testdir/dir2/
    you put yhis in .htaccess :
    Code:
    Redirect 301 /testdir/dir1/ /testdir/dir2/
    Rewrite is for rewriting
    Redirect for redirecting
    Last edited by patryk; 10-14-2012 at 07:57 PM.

  • Users who have thanked patryk for this post:

    ben1390 (10-15-2012)

  • #3
    New Coder
    Join Date
    Nov 2009
    Posts
    61
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Hi patryk

    Thanks for that, much appreciated and I always get my rewrites and redirects confused


  •  

    Posting Permissions

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