Berre Posted January 7, 2015 Share Posted January 7, 2015 (edited) My root directory (in the actual file system) has several subdirectories, one of which is a "main" site, while the others are individual user sites. Every subdirectory has their own .htaccess file, but it's the root .htaccess file that is the topic. I have tried to create rewrite rules myself, but I can't get the rewrite conditions to properly check for the folder existing. /main/lots-of-files /homer/lots-of-files /marge/lots-of-files /bart/lots-of-files /lisa/lots-of-files /maggie/lots-of-files /.htaccess So this is the root of my web server. When I go to sites.example.com I see the directory listing above. I want sites.example.com to point to "/main/" instead of "/". Not only that, but I want everything not specifically pointing to any user dubdirectory to rewrite to /main/. These should not rewrite to /main/, because these directories exists in root*: /homer/index.php /marge /lisa/pictures/profile.gif * The files may not exist in those positions, as /homer/, /marge/, /bart/, /lisa/ and /maggie/ all has a .htaccess file with their own rewrite rules. These should rewrite to /main/: / /philip /bender/bending/rodriguez.php /basically/anything-not-existing-as-a-directory /some-file.txt Edited January 7, 2015 by Berre Quote Link to comment https://forums.phpfreaks.com/topic/293726-rewrite-only-if-first-part-is-not-an-existing-directory/ Share on other sites More sharing options...
CroNiX Posted January 7, 2015 Share Posted January 7, 2015 Maybe these would be useful in your htaccess #If the request is not an actual existing file RewriteCond %{REQUEST_FILENAME} !-f #If the request is not an actual existing directory RewriteCond %{REQUEST_FILENAME} !-d RewriteRule //Your rewrite rule Quote Link to comment https://forums.phpfreaks.com/topic/293726-rewrite-only-if-first-part-is-not-an-existing-directory/#findComment-1502018 Share on other sites More sharing options...
Berre Posted January 7, 2015 Author Share Posted January 7, 2015 Ok. Thanks. I got it to work now. I've attempted using those conditions multiple times, but there seems to have been some issues with caching. Quote Link to comment https://forums.phpfreaks.com/topic/293726-rewrite-only-if-first-part-is-not-an-existing-directory/#findComment-1502074 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.