You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Campbell, Lance" <la...@uiuc.edu> on 2008/02/08 07:47:52 UTC

[users@httpd] Mod rewrite - can it tell if a requested file exists

Apache 2.2

 

I know it is possible to chain mod rewrite rules.  Is it possible with
mod rewrite to test for the existence of a requested file?  

 

Example:

 

Requested URL: http://acme.com/abc/123

 

Sudo Code:

 

If the URL matches /abc/* 

  Then rewrite the URL to /zzz/abc/123

    if the file exists then done (leave the requested file as
/zzz/abc/123)

    else if it does not exist

     then rewrite the URL to /xxx/abc/123 then done

 

Is this possible?  If not then how could you do this as fast as possible
without creating a mod for apache?

 

Thanks,

 

 

Lance Campbell

Project Manager/Software Architect

Web Services at Public Affairs

University of Illinois

217.333.0382

http://webservices.uiuc.edu

 


Re: [users@httpd] Mod rewrite - can it tell if a requested file exists

Posted by Christian Folini <ch...@post.ch>.
Hi Lance,

Have you checked the documentation?
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond

Christian

On Fri, Feb 08, 2008 at 12:47:52AM -0600, Campbell, Lance wrote:
> Apache 2.2
> 
>  
> 
> I know it is possible to chain mod rewrite rules.  Is it possible with
> mod rewrite to test for the existence of a requested file?  
> 
>  
> 
> Example:
> 
>  
> 
> Requested URL: http://acme.com/abc/123
> 
>  
> 
> Sudo Code:
> 
>  
> 
> If the URL matches /abc/* 
> 
>   Then rewrite the URL to /zzz/abc/123
> 
>     if the file exists then done (leave the requested file as
> /zzz/abc/123)
> 
>     else if it does not exist
> 
>      then rewrite the URL to /xxx/abc/123 then done
> 
>  
> 
> Is this possible?  If not then how could you do this as fast as possible
> without creating a mod for apache?
> 
>  
> 
> Thanks,
> 
>  
> 
>  
> 
> Lance Campbell
> 
> Project Manager/Software Architect
> 
> Web Services at Public Affairs
> 
> University of Illinois
> 
> 217.333.0382
> 
> http://webservices.uiuc.edu
> 
>  
> 

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


Re: [users@httpd] Mod rewrite - can it tell if a requested file exists

Posted by Krist van Besien <kr...@gmail.com>.
On Feb 8, 2008 7:47 AM, Campbell, Lance <la...@uiuc.edu> wrote:


> Requested URL: http://acme.com/abc/123
>
>
>
> Sudo Code:
>
>
>
> If the URL matches /abc/*
>
>   Then rewrite the URL to /zzz/abc/123
>
>     if the file exists then done (leave the requested file as /zzz/abc/123)
>
>     else if it does not exist
>
>      then rewrite the URL to /xxx/abc/123 then done

Lets see...

Rewritecond      /my/doc/root/$1      -f
RewriteRule      /abc/(.*)                  /zzz/abc/$1    [L]

RewriteRule      /abc/(.*)                  /xxx/abc/$1

Krist



-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

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