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 5 of 5
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts

    Rewrite / to /folder

    A client has set up shopping cart software in a folder "shop". I don't actually know why but they want all requests to domain.com to go to domain.com/shop

    This is what they have: (I don't know if they wrote it themselves or if the software created it when they installed it in a folder instead of the root)
    Code:
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . shop/index.php
    That works fine for any request eg. domain.com/madeuppath loads the cart 404 and domain.com/realpath loads correctly but domain.com results in a 403 forbidden error. So I added DirectoryIndex shop/index.php then create a new .htaccess in shop that resets the DirectoryIndex back to index.php but there has to be a better/more elegant way than this.

  • #2
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Assuming the rule you have is in a .htaccess file, try adding...

    Code:
    RewriteRule ^$ shop/ [R=301]

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    No luck - still 403 Forbidden.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,854
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . shop/index.php
    You'd need to add another rewrite condition to block all rewrites that already has redirected to /shop folder. Otherwise, your rules may end up in an infinite loop.
    Last edited by abduraooft; 07-23-2011 at 11:38 AM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    That code is what I've already got - if it were going into an infinate loop, wouldn't it give that 'site is not redirecting properly' error?


  •  

    Posting Permissions

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