View Single Post

  #4 (permalink)  
Old 09-30-2004
Justin Koivisto
 
Posts: n/a
Default Re: mod_rewrite On-the-fly Content-Regeneration not working

DrTebi wrote:

> On Thu, 30 Sep 2004 13:13:50 +0000, Justin Koivisto wrote:
>
>
>>DrTebi wrote:
>>
>>
>>>Hello,
>>>After reading the URL rewriting guide and several other documents, I
>>>still haven't figured this out.
>>>Basically this what I am trying to approach:
>>>- User requests domain.com/page.html
>>>- mod_rewrite checks if requested page exists in
>>> domain.com/static/page.html
>>>- if page does exist, it's served
>>>- if it does not exist, mod_rewrite redirects to domain.com/page.php
>>>- domain.com/page.php generates domain.com/static/page.html
>>>
>>>So, assuming the original URL is domain.com/page.html
>>>here are my last two (failed) attempts:
>>># Attempt 1:
>>># enable the rewrite module
>>>RewriteEngine on
>>>
>>># use static html file if exists (from static/)
>>>RewriteRule ^(.*)\.html$ $1 [C,E=WasHTML:yes]
>>>
>>>RewriteCond static%{REQUEST_FILENAME}.html -f
>>>RewriteRule ^(.*)$ static$1.html [S=1]

>>
>>Did you try the following at all?
>>
>>RewriteCond static/%{REQUEST_FILENAME}.html -f
>>RewriteRule ^(.*)$ static/$1.html [S=1]

>
> I just tried that, but it did not work either unfortunately.
> What exactly is in "%{REQUEST_FILENAME}" if, let's say the URL is
> http://domain.com/page.html
> shouldn't that be "page.html"? Or "/page.html"?
>
> still confused :(


Umm.. neither... more like: "/home/user/www/page.html", so change to this:

RewriteCond static%{REQUEST_URI} -f
RewriteRule ^(.*)$ static/$1.html [S=1]

--
Justin Koivisto - spam@koivi.com
http://www.koivi.com