|
|
|
|
||||||
| alt.apache.configuration Apache web server configuration issues. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I want to rewrite the following:
http://xxxxx.mydomain.com/yyyy/files/[various_files_and_subdirectories] This should really translate to a subdirectory on our apache web server that points to: /usr/local/www/mysite/xxxxx/yyyy/ This directory needs to be authenticated using mod_auth_pgsql where I can use the parameters of: xxxxx and yyyy PLUS a username and password entered (using AuthType basic) to authenticate if the user is allowed to access this directory. Normally this would use .htaccess, but is it possible to do this more dynamically so we do not need to generate an .htaccess file for every directory? I can build a SQL statement using mod_auth_pgsql, so thats not a problem, but how do I pass in xxxx and yyyy into that sql statement. I assume I can use mod_rewrite in some form, but am looking for some advice. Any is greatly appreciated. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On May 4, 6:45 pm, tgh...@gmail.com wrote:
> I want to rewrite the following:http://xxxxx.mydomain.com/yyyy/files/[various_files_and_subdirectories] > > This should really translate to a subdirectory on our apache web > server that points to: > /usr/local/www/mysite/xxxxx/yyyy/ > > This directory needs to be authenticated using mod_auth_pgsql where I > can use the parameters of: > xxxxx and yyyy PLUS a username and password entered (using AuthType > basic) to authenticate if the user is allowed to access this > directory. > > Normally this would use .htaccess, but is it possible to do this more > dynamically so we do not need to generate an .htaccess file for every > directory? > > I can build a SQL statement using mod_auth_pgsql, so thats not a > problem, but how do I pass in xxxx and yyyy into that sql statement. > > I assume I can use mod_rewrite in some form, but am looking for some > advice. > > Any is greatly appreciated. what is the document root for this server, we need to know that really!! Also I am assuming that xxxxx and yyyy stands for a word [you say "...really translate to /a/ subdirectory..." but later are worried about ".htaccess files for /each/ subdirectory so I'm confused] not a variable, otherwise you can use an AliasMatch - probably - but it depends. In the config section for the servername in question xxxxx.mydomain.com place an alias Alias /yyyy/files /usr/local/www/mysite/xxxxx/yyyy job done. However dont go and create the folder "files" under /yyyy on the filesystem or you will find that requesting http://xxxxx.mydomain.com/yyyy/files actually takes you to /usr/local/www/mysite/xxxxx/yyyy rather than /usr/local/www/mysite/xxxxx/yyyy/files as you might expect without the Alias. Rewrites? [A big assumption but] assuming the document root is /usr/local/www/mysite/ you could start with ReWriteCond %{HTTP_HOST} ^xxxxx\.mydomain\.com$ #the rewriterule will only be matched if the domain is right #and the url starts with yyyy/files #warning dont create the folder "files" with subfolders, under the folder "files" #or you will create an infinite loop, that requires another rewritecond to stop ReWriteRule ^/yyyy/files/(.+) /xxxxx/yyyy/$1 [L] this /xxxxx/yyyy/$1 is appended to the doc root, making the required url of /usr/local/www/mysite/xxxxx/yyyy/[various_files_and_subdirectories] however whats different between that and simply using the url: http://xxxxx.mydomain.com/xxxxx/yyyy/[various_files_and_subdirectories] I am assuming therefore that you have a large amount of webpages that contain the old-style links. Obviously if your servername's doc root is below mysite/ but not inside xxxxx then you're stuffed. as you cant rewrite a url to something that when appended to /usr/local/www/mysite/ppppp/ it becomes /usr/local/www/mysite/xxxxx/yyyy/[various_files_and_subdirectories] Hence the word "advanced" in your title perhaps?? As to mod_auth_pgsql, have you hacked the source of this mod? What directives were you planning to use to pass xxxxx and yyyy across to the query and hence to the database, I can't see one you could use, but perhaps I am too tired! IMHO you can't do this.If you can use httpd.conf, do so [provided you decide not to go "dynamic" with your .htaccess files], switching off .htaccess using AllowOverride None The question of dynamically dealing with subdirectories, you could probably use LocationMatch or DirectoryMatch - again probably - depending on what those folders are named, you can normally create a simple reg exp for the different possibilities! As above, using .htaccess files means you can dynamically generate them without server restart, so if you have many different xxxxx and yyy dirs then .htaccess is all you have. Use the same script that you use to create the dirs, to create the .htaccess files. There is one problem, which user is able to access which dir and sub dir, if there are only 2 [xxxxx and yyyy] great, but if you are using hundreds how do you intend to group the users which can from those which cant. My advice is to use a php/perl/bash script to create/modify the htaccess files naming [creating/removing] the users in the actual files as required. If it is just one user per folder, then drop the complexity and just have the folders named after the users. The username and password is being passed in the request headers in each request after the basic auth was successful anyway, so its no less secure to have the folders named after the users. Of course though true security should be handled simply by scripting using a server side scripting language, then all of these rewrites aliases, and database query restrictions are irrelevant, just code a quick couple of pages of php and you're done, new users the directories on the filesystem and which each user can access is just another table away. Sorry I feel like Ive written a lot and been of no at all! |
|
![]() |
| Outils de la discussion | |
|
|