...

View Full Version : Rewrite / to /folder



NancyJ
07-21-2011, 07:00 PM
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)


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.

Cags
07-23-2011, 09:31 AM
Assuming the rule you have is in a .htaccess file, try adding...


RewriteRule ^$ shop/ [R=301]

NancyJ
07-23-2011, 11:11 AM
No luck - still 403 Forbidden.

abduraooft
07-23-2011, 11:35 AM
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.

NancyJ
07-23-2011, 01:40 PM
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?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum