Forum Moderators: phranque
/domains/domain1.com/
/domains/domain2.com/
The domains on disk can contain images or other files but if domain folder on disk has no index file I would like to show a php page /domains/index.php
What I tried is this but it is wrong:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^domains/([^/]*)/$ /domains/index.php?domain=$1
What is the right approach? Can I test something like this?
if !file_exists index.php [AND]
if !file_exists index.html
then go to /domains/index.php?domain=$1
If that would be correct, how to I write this in .htaccess?
Thank you.
RewriteCond if ! file_exists /domains/(the_domain)/index.php
RewriteRule ^domains/([^/]*)/$ /domains/index.php?domain=$1
What is correct way to write that cond on first line?
Considering above in my code I have this, redirecting all to local folder (without "www"):
RewriteCond %{HTTP_HOST} ^(www.)?([^.]*)\.(.*)$ [NC]
RewriteRule ^(.*)$ /domains/%2.%3/$1 [L,QSA]
Then would this test be ok to test for index file exists?
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule ^domains/([^/]*)/$ /domains/?domain=$1
It appears to work ok.
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteRule ^domains/([^/]*)/$ /domains/?domain=$1
But if there are no other 'index' page-paths under /domains, then it should work just fine in /domains/.htacess
Jim
About the "mod_dir" that you mentioned in this last post, I didn't get it; from what I read from you, maybe you thought my .htaccess is under /domains/.htaccess ?! But the htaccess is in root. Is that irrelevant if I use the last 3 htaccess lines above?
In case it's not clear, every directory can have its own .htaccess file both for efficiency (however you define it on the scale between execution efficiency and administration efficiency) and to control the 'scope' of the directives in that .htaccess file.
Jim