You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Gary Smith <ga...@primeexalia.com> on 2004/03/15 17:54:25 UTC

RE: [users@httpd] Alias all files to one script ?

Nasty?  It's transparent.  There are other alternatives.  I beleive that I stumbled across a mod some time ago to do kinda what you want to do but it's implementation is much nastier.
 
The single file pointing to a single PHP page (which is your custom 404) does exactly what you want and the user won't see what there is no page.  You only need one .htaccess file in the base directory that you want to control the 404 of.
 
We have used something similar to trick the search engines.  We map .html to be parsed by PHP (not as a cgi) and then we have a page that pulls random words and puts them into random pages (that are generated on the fly).  We then keep track of what page used what random words.  The page also contains a list of IP's that make of the search engines.  So when a client goes to that page they are redirected to the proper site and it's all transparent.  We used the method below to handle that.
 
Gary

	-----Original Message----- 
	From: ing.Martin Prášek [mailto:prasek@silesia.cz] 
	Sent: Mon 3/15/2004 8:39 AM 
	To: users@httpd.apache.org 
	Cc: 
	Subject: Re: [users@httpd] Alias all files to one script ? 
	
	

	Full error log and  trashed access log is not a problem, because application handle logging by itself (ie put it to database ).
	An yes, I need to cover a  complettly random  url (ie www.foo.com/bar/random/subdirectory/and/random_file ). All presented ways seems to can work but looks terrible nasty. Is there a better way to do this ?
	
	
	
	----- Původní zpráva -----
	Od: "Henry" <he...@ix.netcom.com>
	Komu: <us...@httpd.apache.org>
	Odesláno: 15. března 2004 12:56
	Předmět: Re: [users@httpd] Alias all files to one script ?
	
	
	>Create the directory /bar and then put the 404 entry into the .htaccess file.
	
	I do not agree with this method at all.  Your error log will be full of file not found messages, as well as you regular log will have 404 status for every single request.  If that doesn't matter to you, then sure, go for it.
	
	On the other hand, I would suggest creating a symbolic link from the requested filename to your  http://www.foo.com/scripts/myscript.php4 script.  This will cover all known files, but doesn't work if you're expecting any random name to be requested.  You could use both methods - the 404 method will catch anything you don't already have symbolically linked.
	
	-Hank
	----- Original Message -----
	From: "Gary Smith" <ga...@primeexalia.com>
	To: <us...@httpd.apache.org>
	Sent: Monday, March 15, 2004 5:09 AM
	Subject: RE: [users@httpd] Alias all files to one script ?
	
	
	
	
	/bar/.htaccess:
	ErrorDocument 404 /scripts/myscript.php4
	
	This will override the default directory settings (or add to them) for the directory path inside of the httpd.conf file.  This does assume that override is allowed in the httpd.conf file.  You can have a similar one in the / and the /bar/.htaccess will override it for that one directory (and it's subdirs) only.
	
	Hope this helps
	
	
	Gary Wayne Smith
	
	
	
	
	-----Original Message-----
	From: ing.Martin Prášek [mailto:prasek@silesia.cz]
	Sent: Monday, March 15, 2004 1:59 AM
	To: users@httpd.apache.org
	Subject: [users@httpd] Alias all files to one script ?
	
	On server www.foo.com there is directory /bar in server root. I need  to do some configuration changes to Apache (1.3.26) in my box to fulfill the following requirements:
	
	If there comes a request for www.foo.com/bar/whatever Apache should not return "whatever", to client, but should run "www.foo.com/scripts/myscript.php4" and return its output (ie myscript.php4 take a responsibility what will be returned to client). This should be done for every request for files and subdirectories inside /bar and even for /bar directory itself. Note that I need preserve (ie feed to myscript.php4) as much request variableas as posssible (ip adress of clients, GET, POST and COOKIES, HTTP headers etc).
	
	
	For some raeson I do not want PHP to run as CGI too. It should be transparent for clients, so  3xx status code (redirection) is not solution for me. 
	
	i read the documentation and I find only AddHandler and AddAction, but seems it allow only to call a CGI program and match only extensions (fix me if I am wrong).
	
	Tnanx for help.
	
	PS: Execuse my bed English.
	
	---------------------------------------------------------------------
	The official User-To-User support forum of the Apache HTTP Server Project.
	See <URL:http://httpd.apache.org/userslist.html> for more info.
	To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
	   "   from the digest: users-digest-unsubscribe@httpd.apache.org
	For additional commands, e-mail: users-help@httpd.apache.org
	
	
	---------------------------------------------------------------------
	The official User-To-User support forum of the Apache HTTP Server Project.
	See <URL:http://httpd.apache.org/userslist.html> for more info.
	To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
	   "   from the digest: users-digest-unsubscribe@httpd.apache.org
	For additional commands, e-mail: users-help@httpd.apache.org
	
	
	
	---------------------------------------------------------------------
	The official User-To-User support forum of the Apache HTTP Server Project.
	See <URL:http://httpd.apache.org/userslist.html> for more info.
	To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
	   "   from the digest: users-digest-unsubscribe@httpd.apache.org
	For additional commands, e-mail: users-help@httpd.apache.org
	
	
	---------------------------------------------------------------------
	The official User-To-User support forum of the Apache HTTP Server Project.
	See <URL:http://httpd.apache.org/userslist.html> for more info.
	To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
	   "   from the digest: users-digest-unsubscribe@httpd.apache.org
	For additional commands, e-mail: users-help@httpd.apache.org