Jump to content

Configure Apache For Multiple Root Folders


lazytiger

Recommended Posts

I'm trying to mirror my website on my local machine for development. I'm having a little problem with relative links, though. In my TCH account, public_html is the root folder as far as Apache is concerned. But on my machine at home, which is running OS X, the root folder is /Users/jeff/Sites. Now, within that folder I have several folders containing different websites. I'm trying to figure out how to configure Apache to use each folder (website) within /Users/jeff/Sites as the root folder while I'm viewing files within a given folder. Of course I could change my relative links to work locally, but then I'm not really mirroring!

 

i.e., specify that /Users/jeff/Sites/lazytiger is the root file while viewing files in that folder, and specifying that /Users/jeff/Sites/bluestars is the root while viewing files in that folder.

 

I figured this would or could be set in an .htaccess file for each folder, but I have yet to figure out a setting that doesn't result in an Apache error. I tried tinkering with virtual host settings too, but that seems like overkill for what I'm trying to do. (and I couldn't get it to work anyway)

 

Please help! Thanks.

 

Jeff

Link to comment
Share on other sites

I think the best answer would depend on what URLs you are using on your local machine to access these pages. Without knowing that, I can't really tell you any details on how you would implement a particular solution.

 

You may be able to use one of the following methods to do what you want:

 

1) VirtualHost directives in httpd.conf file

2) Alias directives in httpd.conf file

3) mod_rewrite directives in httpd.conf file or .htaccess files

 

Hope this helps...

Link to comment
Share on other sites

Through Apache, the address is http://localhost/~jeff, which corresponds to /Users/jeff/Sites in the real folder hierarchy. Deeper folders are identical.

 

I know only of the methods you speak - I don't really know how to properly implement any of them. All I accomplished from searching for help pages and tinkering with httpd.conf was Apache error messages! Could you get me started now with the URLs? Please? Thanks!

Link to comment
Share on other sites

It seems like using mod_vhost_alias is a step in the right direction. In the Apache documentation, it says to set UseCanonicalName to "off" and then set the VirtualDocumentRoot directive to the local folder using directory name interpolation. As best as I can figure, I should set it to something like /Users/jeff/Sites/%0. The %0 variable just tells it to use the entire address, in my case it's the name of the each folder under the Sites folder. (lazytiger, bluestars, etc.)

 

But then Apache won't even restart after editing the httpd.conf file as such, so obviously what I'm doing is incorrect. Any ideas?

Link to comment
Share on other sites

I think you'd need to use an actual domain name for each site that you want to set up a separate DocumentRoot for. Once you've done that, then you can set up a VirtualHost on the web server for each domain.

 

Make up a domain name for each site, and add it to the /etc/hosts file on your server so the domain name will resolve and point back at your machine. In the /etc/hosts file, it should already have the following in it at a minimum:

>127.0.0.1    localhost

I'm going to suggest here 'jeff.com' as the main 'dummy' domain, and set up each site as a subdomain of 'jeff.com'. For the two sites you've mentioned, we'll use 'lazytiger.jeff.com' and 'bluestars.jeff.com' as the new domains we want your machine to recognize. Add these subdomains to your /etc/hosts file and point them at your machine (127.0.0.1):

>127.0.0.1    localhost
127.0.0.1    lazytiger.jeff.com
127.0.0.1    bluestars.jeff.com

After you've made these changes and saved them, I believe you'll need to restart your network so the /etc/hosts file will be re-read.

 

Once you have the domain names set up in /etc/hosts, then you can set up a VirtualHost on the web server for each one. In your httpd.conf file:

>NameVirtualHost *:80

<VirtualHost *:80>
   ServerName localhost
   DocumentRoot /Users/jeff/Sites
</VirtualHost>

<VirtualHost *:80>
   ServerName lazytiger.jeff.com
   DocumentRoot /Users/jeff/Sites/lazytiger
</VirtualHost>

<VirtualHost *:80>
   ServerName bluestars.jeff.com
   DocumentRoot /Users/jeff/Sites/bluestars
</VirtualHost>

The first VirtualHost block is necessary because it will be the configuration used if the host name in a request does not match any of domain names specified by the ServerName directive in any VirtualHost block. (The first VirtualHost block is a 'default'.) I don't know what you've configured as 'ServerName' in the main section of your httpd.conf file - whatever you've configured there, you should use the same thing for the ServerName in the first VirtualHost block.

 

After you've added the virtual hosts and saved the httpd.conf file, then you'd need to restart the web server.

 

You should now be able to view your sites by browsing to http://lazytiger.jeff.com/ and http:/bluestars.jeff.com/. Each site will use the DocumentRoot specified, and your relative URLs/links should work correctly.

 

I've tested this on a Windows server running Apache, and it works as I have explained it. You may need to make minor adjustments if I've misunderstood something about your machine or web server configuration (Apache on OS X).

 

Hope this helps...

Link to comment
Share on other sites

Thank you very much for your help! I followed your instructions for setting up virtual hosts (except I used "lazytiger.local" for the domain), and it seems to be working. I haven't had a chance to really test it yet, but so far so good I think. I thought virtual hosts seemed like more than was necessary for simply defining root directories, but it seems to do the trick and really is as simple as any other method. Your quick tutorial was exactly what I needed.

 

Thanks again! I'm glad I use TCH for hosting. I know these boards are well-monitored by you guys.

Link to comment
Share on other sites

Glad to hear you've got it working! ;)

 

I thought a lot about your problem and didn't see any way to effectively solve it without having separate domain names for each site. It took me a while to remember that you could set up dummy domains to point at 127.0.0.1 in /etc/hosts, and after that, solving the problem got much easier. ;)

 

I was originally going to suggest 'lazytiger.localdomain' for the domains, but I wasn't 100% sure if that would work or not. I like the '.local' even better - it's shorter, and therefore easier to remember and type. :thumbup1:

Link to comment
Share on other sites

Virtual hosting is working just fine, but now I have another problem. I can't figure out how to use .htaccess files. I've seen the same instructions all over the web: find the "AllowOverride" option(s) in httpd.conf and set it to "All", and then repeat that for userfile.conf (or maybe set it to AuthConfig). But it's simply not working for me. Apache absolutely balks at any directory that has an .htaccess file in it, giving me an internal server error when trying to access anything in the folder. Obviously it doesn't like whatever I'm trying to put in the .htaccess file, which is this:

 

 

>DirectoryIndex sp_index.php

RewriteEngine On 

RewriteRule ^folder/(.*) sp_index.php?dir=./$1
RewriteRule ^file/(.*) sp_index.php?file=./$1
RewriteRule ^thumb/(.*) sp_getthumb.php?source=$1

 

But even if I take out the DirectoryIndex line, or conversely, take out all the Rewrite lines, it still won't work. What the heck?!

Link to comment
Share on other sites

I finally had a chance to check the error log. It's over 6000 lines long from only a week's worth of activity! Tons and tons of repeated errors. (I had several dozen pictures in the directory... that was a huge mistake when it comes to debugging!) Anyway, I think I found some relevant lines:

 

>[Tue Sep  6 23:14:46 2005] [error] [client 127.0.0.1] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /Users/jeff/Sites/lazytiger/visual

[Tue Sep  6 23:11:47 2005] [alert] [client 127.0.0.1] /Users/jeff/Sites/lazytiger/visual/.htaccess: DirectoryIndex not allowed here

 

For the first error, I'm not sure what to do about that. With the second error, I'm thinking... well, yeah! I kinda figured it's not allowed since it hasn't worked! Not very helpful for fixing it!

Link to comment
Share on other sites

You may have multiple AllowOverride directives in your httpd.conf, each of which applies to a different directory. I'd probably recommend placing AllowOverride directives within each of the VirtualHost blocks you set up for your sites:

>NameVirtualHost *:80

<VirtualHost *:80>
  ServerName localhost
  DocumentRoot /Users/jeff/Sites
  <Directory /Users/jeff/Sites>
     AllowOverride All
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  ServerName lazytiger.local
  DocumentRoot /Users/jeff/Sites/lazytiger
  <Directory /Users/jeff/Sites/lazytiger>
     AllowOverride All
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  ServerName bluestars.local
  DocumentRoot /Users/jeff/Sites/bluestars
  <Directory /Users/jeff/Sites/bluestars>
     AllowOverride All
  </Directory>
</VirtualHost>

This should allow you to use the .htaccess directives that you're wanting to use.

Link to comment
Share on other sites

I'm still getting the first error (Options FollowSymLinks or SymLinksIfOwnerMatch is off ...) but not the second, for whatever reason. When I try to access the folder through the web browser, I get a "403 Forbidden" message. I've checked all the permissions; the directory and everything in it is 755, although the contents probably only need to be 744.

 

??

Link to comment
Share on other sites

Correction! I am able to view the folder now. I forgot to sudo when opening my user.conf file, and some changes I thought I had made hadn't been saved. The .htaccess file is working now because it's going to the correct index page.

 

BUT, there are still a lot of errors. I have PHP scripts for the gallery to create and store thumbnails and stuff (not written by me, so it should work!), but apparently the script does not have permission to create directories. mod_rewrite doesn't seem to be working, even though it's requested in .htaccess. mod_rewrite is loaded as far as I can tell in the httpd.conf file.

Link to comment
Share on other sites

Thanks. I'm still having one last issue, though. I'm trying to install a photo gallery software package called Simple PHP Gallery. (not simple enough, eh?) SPG uses GD to create thumbnails, and then it creates a folder to cache the thumbnails in. I know GD is working, but caching doesn't seem to be. I'm assuming it's because SPG doesn't have rights to create or read/write to the cache folder. I even manually created it, but SPG doesn't write anything into it. All SPG files are set to 755, but still caching doesn't work. I get the following errors in the Apache error log file:

 

>[Sat Sep 10 12:55:43 2005] [error] PHP Notice:  Undefined index:  dirinfo in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 67 
[Sat Sep 10 12:55:43 2005] [error] PHP Notice:  Undefined index:  misc in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 94 
[Sat Sep 10 12:55:43 2005] [error] PHP Notice:  Undefined index:  file in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 100 
[Sat Sep 10 12:55:43 2005] [error] PHP Notice:  Undefined index:  file in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 101 
[Sat Sep 10 12:55:43 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 170 
[Sat Sep 10 12:55:43 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 181 
[Sat Sep 10 12:55:43 2005] [error] PHP Notice:  Undefined index:  title in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 318 
[Sat Sep 10 12:55:43 2005] [error] PHP Notice:  Undefined index:  misc in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 318 
[Sat Sep 10 12:55:43 2005] [error] PHP Notice:  Undefined index:  misc in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 39 
[Sat Sep 10 12:55:44 2005] [error] PHP Warning:  imagejpeg(): Unable to open 'cache/66de43b7ac7dc89f62f14af0200ad092.jpg' for writing in /Users/jeff/Sites/lazytiger/visual/sp_getthumb.php on line 47 
[Sat Sep 10 12:55:44 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_getthumb.php on line 57 
[Sat Sep 10 12:55:44 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_getthumb.php on line 59 
[Sat Sep 10 12:55:44 2005] [error] PHP Notice:  Undefined variable:  content in /Users/jeff/Sites/lazytiger/visual/sp_getthumb.php on line 74 
[Sat Sep 10 12:55:44 2005] [error] PHP Warning:  fopen(cache/cache.ini): failed to open stream: Permission denied in /Users/jeff/Sites/lazytiger/visual/sp_getthumb.php on line 83 
[Sat Sep 10 12:55:45 2005] [error] PHP Notice:  Undefined index:  dirinfo in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 67 
[Sat Sep 10 12:55:45 2005] [error] PHP Notice:  Undefined index:  title in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 94 
[Sat Sep 10 12:55:45 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 129 
[Sat Sep 10 12:55:45 2005] [error] PHP Notice:  Undefined index:  misc in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 318 
[Sat Sep 10 12:55:45 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 318 
[Sat Sep 10 12:55:45 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 348 
[Sat Sep 10 12:55:45 2005] [error] PHP Notice:  Use of undefined constant PHP_SELF - assumed 'PHP_SELF' in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 100 
[Sat Sep 10 12:55:45 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 123 
[Sat Sep 10 12:55:45 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 129 
[Sat Sep 10 12:55:49 2005] [error] PHP Notice:  Undefined index:  dirinfo in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 67 
[Sat Sep 10 12:55:49 2005] [error] PHP Notice:  Undefined index:  title in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 94 
[Sat Sep 10 12:55:49 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 129 
[Sat Sep 10 12:55:49 2005] [error] PHP Notice:  Undefined index:  misc in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 318 
[Sat Sep 10 12:55:49 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 318 
[Sat Sep 10 12:55:49 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 348 
[Sat Sep 10 12:55:49 2005] [error] PHP Notice:  Use of undefined constant PHP_SELF - assumed 'PHP_SELF' in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 100 
[Sat Sep 10 12:55:49 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 123 
[Sat Sep 10 12:55:49 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 129

 

here's a link to the configuration info for SPG:

 

http://relativelyabsolute.com/spg/instructions.php

 

Any ideas?

Link to comment
Share on other sites

I hope all these steps help someone else someday... :blink: Because I should probably be figuring out some of this stuff before I run and post something on the forum.

 

OK. SPG is able to create the cache files now that I've set everything to 777. It's on my local machine, so I'm not worried about security. But what about when I finally upload this stuff to my TCH account? It shouldn't need to be 777, should it?

 

Also, I'm still getting some Apache errors:

 

>[Sat Sep 10 14:38:48 2005] [error] PHP Notice:  Undefined index:  dirinfo in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 67
[Sat Sep 10 14:38:48 2005] [error] PHP Notice:  Undefined index:  title in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 94
[Sat Sep 10 14:38:48 2005] [error] PHP Notice:  Undefined index:  file in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 100
[Sat Sep 10 14:38:48 2005] [error] PHP Notice:  Undefined index:  file in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 101
[Sat Sep 10 14:38:48 2005] [error] PHP Notice:  Undefined index:  misc in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 191
[Sat Sep 10 14:38:48 2005] [error] PHP Notice:  Undefined index:   in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 318
[Sat Sep 10 14:38:50 2005] [error] PHP Notice:  Undefined index:  dirinfo in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 67
[Sat Sep 10 14:38:50 2005] [error] PHP Notice:  Undefined index:  misc in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 94
[Sat Sep 10 14:38:50 2005] [error] PHP Notice:  Undefined index:  file in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 100
[Sat Sep 10 14:38:50 2005] [error] PHP Notice:  Undefined index:  file in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 101
[Sat Sep 10 14:38:50 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 170
[Sat Sep 10 14:38:50 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 181
[Sat Sep 10 14:38:50 2005] [error] PHP Notice:  Undefined index:  title in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 318
[Sat Sep 10 14:38:50 2005] [error] PHP Notice:  Undefined index:  misc in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 318
[Sat Sep 10 14:38:50 2005] [error] PHP Notice:  Undefined index:  misc in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 39
[Sat Sep 10 14:38:51 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_getthumb.php on line 57
[Sat Sep 10 14:38:51 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_getthumb.php on line 59
[Sat Sep 10 14:38:51 2005] [error] PHP Notice:  Undefined variable:  content in /Users/jeff/Sites/lazytiger/visual/sp_getthumb.php on line 74
[Sat Sep 10 14:38:54 2005] [error] PHP Notice:  Undefined index:  dirinfo in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 67
[Sat Sep 10 14:38:54 2005] [error] PHP Notice:  Undefined index:  title in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 94
[Sat Sep 10 14:38:54 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_def_vars.php on line 129
[Sat Sep 10 14:38:54 2005] [error] PHP Notice:  Undefined index:  misc in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 318
[Sat Sep 10 14:38:54 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 318
[Sat Sep 10 14:38:54 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 348
[Sat Sep 10 14:38:54 2005] [error] PHP Notice:  Use of undefined constant PHP_SELF - assumed 'PHP_SELF' in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 100
[Sat Sep 10 14:38:54 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 123
[Sat Sep 10 14:38:54 2005] [error] PHP Notice:  Undefined index:  Tux.jpg in /Users/jeff/Sites/lazytiger/visual/sp_helper_functions.php on line 129

 

Undefined index!!! Yeah, I see it's a problem! Thanks, Apache! How do I fix it?

Link to comment
Share on other sites

OK. SPG is able to create the cache files now that I've set everything to 777. It's on my local machine, so I'm not worried about security. But what about when I finally upload this stuff to my TCH account? It shouldn't need to be 777, should it?

If you want PHP to be able to create files in the cache directory, it will need to have 0777 permissions.

 

The 'Undefined index:' errors are not Apache errors - they're errors in the PHP code. (That's why the error messages begin with 'PHP Notice:'.) 'Undefined index' in this context means 'undefined array index'.

 

The fix for the first error appears to be here (Skyzyx Support Forums). Another user appears to have posted fixes addressing many of the other errors you're receiving here.

Link to comment
Share on other sites

Thanks for looking around for answers for me. Truly, TCH rocks. :P I've looked through those threads already, and I'm starting to think that SPG isn't worth the trouble. I don't want to use code that I have to track down bugs myself just to make it useable! Well, technically I guess it does work, but I'd prefer that my error_log file not be 10MB after a month.

 

The gallery I've been using, SPGM (Simple Picture Gallery Manager), is a lot simpler (basically, it's just a single 64K php file) and less buggy. The one main feature I wish it had that it doesn't is "prettified" URLs. If I could figure out how to set it up to use mod_rewrite, I'd be very happy. Unfortunately, I'm not a programmer at all, and that might be a tricky first attempt. But I'm thinking about it. I'm searching for others who have wanted the same thing; I've found some hacks that I'm going to try out.

Edited by lazytiger
Link to comment
Share on other sites

If you'd just like to make the error messages go away, you should be able to do so by lowering PHP's error reporting level so 'notice' warnings are not logged.

 

In your php.ini file, you can use the following:

>error_reporting E_ALL & ~E_NOTICE

Or, in your httpd.conf file or an .htaccess file, you could use this instead:

>php_value error_reporting 2039

This is actually the normal 'default' setting for error reporting, so this should give you the same behavior as what you would see on a production server.

Link to comment
Share on other sites

Thanks for the error suppression tips. Though, I think I'd actually prefer to continue using SPGM. It's a simpler, smaller package and I don't know of any glaring errors in it such as those in SPG. The one issue that I hope to resolve is to have it use mod_rewrite. I'm very close. I found these two sources of information:

 

http://www.schilken.de/weblog/archives/200...static-urls.htm

http://blog.anhtran.info/2005/04/17/mod_rewrite-for-albums/

 

The second one seems to be more thorough in its approach, but note my comments on that page. I haven't been able to get it to work; the "pretty" URLs seem to be real URLs that just dump me into my directory listings! I've asked the guy for help, but who knows if or when he'll respond.

 

Here is the relevant part of my spgm.php file:

 

>$html_buffer = ob_get_contents(); // read buffer into string variable
ob_end_clean(); // end buffering // clear buffer
if ($html_buffer)
{ // search/replace to get the good urls
$search = array('index.php?spgmGal=', '&spgmPage=1&spgmPic=0&spgmFilters=s' , '&spgmPic=', '&spgmPage=' , '&spgmFilters=pic' , '&spgmFilters=t' , '&spgmFilters=' , 'index.php?spgmFilters=' , 'src="');
$replace = array('/visual/gal/' , '/slideshow/' , '/', '/page/', '/pic/' , '/nothumb/' , '' , '' , 'src="http://lazytiger.local/visual/');
echo str_replace($search, $replace, $html_buffer);
}

 

And here is my .htaccess file:

 

>RewriteEngine on
RewriteRule ^visual/gal/(([^/]+[/]{0,1}){1,})/page-([0-9]+)$ index.php?spgmGal=$1&spgmPage=$3 [L]
RewriteRule ^visual/gal/(([^/]+[/]{0,1}){1,})/slideshow$ index.php?spgmGal=$1&spgmPage=1&spgmPic=0&spgmFilters=s [L]
RewriteRule ^visual/gal/(([^/]+[/]{0,1}){1,})/([0-9]+)$ index.php?spgmGal=$1&spgmPic=$3&spgmFilters=#pic [L]
RewriteRule ^visual/gal/(([^/]+[/]{0,1}){1,})/([0-9]+).jpg$ index.php?spgmGal=$1&spgmPic=$3&spgmFilters=t#pic [L]
RewriteRule ^visual/gal/(([^/]+[/]{0,1}){1,})$ index.php?spgmGal=$1 [L]

 

It's working... I mean, I'm not getting any errors in the log file. But the program isn't working - it's just giving me literal directory listings. Any ideas?

 

And thank you very, very, much for indulging me thus far.

Link to comment
Share on other sites

  • 3 months later...

This is a fascinating thread -- sheds a lot of insight into a problem I'm working with. I've got a similar objective, but I'm wondering about scale. Anybody worked with virtualhost on the order of thousands of hosts?

 

Is there a way to simply say, any domain is located in the folder with the same name?

 

For instance, if my root is /users/tom/webroot

 

And then I hit the server looking for "siteA.com", it would automatically serve the index page from

 

/users/tom/webroot/siteA/

 

It seems, for thousands of sites, it would work better to set a generic rule, than to have thousands of virtualhost entries.

 

What do you (wiser, more experienced) folks think?

Link to comment
Share on other sites

I'm also considering using mod_rewrite to take care of the problem, but I'm so woefully unfamiliar with regex that it doesn't make much sense to me. Here's an example I found that looks promising:

 

=================

 

Virtual User Hosts

 

Description:

Assume that you want to provide www.username.host.domain.com for the homepage of username via just DNS A records to the same machine and without any virtualhosts on this machine.

Solution:

For HTTP/1.0 requests there is no solution, but for HTTP/1.1 requests which contain a Host: HTTP header we can use the following ruleset to rewrite http://www.username.host.com/anypath internally to /home/username/anypath:

 

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www\.[^.]+\.host\.com$

RewriteRule ^(.+) %{HTTP_HOST}$1 [C]

RewriteRule ^www\.([^.]+)\.host\.com(.*) /home/$1$2

 

==================

 

I'd want to just provide siteA.com or www.siteA.com... I dunno if this is any help. I suppose if I really knew how mod_rewrite works, I'd be much better off, huh?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...