httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin French <jus...@indent.com.au>
Subject Re: [users@httpd] mod_rewrite or Multiviews or custom 404???
Date Fri, 09 Jan 2004 00:48:20 GMT
Following up to my own post, for archive's sake...

On Thursday, January 8, 2004, at 02:03  PM, Justin French wrote:

> I'd like an generic solution to the following problem:
>
> if a url exists (eg /dir/dir/file.html)
> 	-> apache serves the url as per normal
> else
> 	-> the request is passed to /index.php (but the url remains as 
> entered in the browser)
>
> I'm intending to use /index.php as a fusebox-style front controller 
> script, but don't want to loose the ability to manually add 
> directories and files that *don't* use the fusebox.

!-f and !-d modifiers (among others) can check if the file or directory 
can be found/accessed, which is exactly what i needed :)


<IfModule mod_rewrite.c>
	RewriteEngine On
	# if is not a file
		RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
	# OR not a directory
		RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d
	# rewrite
		RewriteRule (.*) /path/to/index.php?request=$1
</IfModule>


Rewrites:
	- http://site.com/dir/dir/page.html
	- http://site.com/dir/dir/
To:
	- http://site.com/path/to/index.php?request=dir/dir/page.html
	- http://site.com/path/to/index.php?request=dir/dir/

Which I can then parse with PHP for my fusebox-style app.


Regards,
Justin French


---------------------------------------------------------------------
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


Mime
View raw message