PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > alt.apache.configuration > advanced htaccess/httpd.conf and modrewrite issue
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
alt.apache.configuration Apache web server configuration issues.

advanced htaccess/httpd.conf and modrewrite issue

Réponse
 
LinkBack Outils de la discussion
Vieux 04/05/2007, 18h45   #1
tgh003@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut advanced htaccess/httpd.conf and modrewrite issue

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.

  Réponse avec citation
Vieux 05/05/2007, 00h57   #2
shimmyshack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: advanced htaccess/httpd.conf and modrewrite issue

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!

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 06h47.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11537 seconds with 10 queries