You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Scott Lamb <sl...@slamb.org> on 2002/08/15 02:19:49 UTC
mod_rewrite: Rewriting .html to .shtml if no .html exists
I'm trying to make .html URLs work whether a page is preprocessed with
SSI or not. (While not invoking the overhead of pre-processing all .html
documents.)
Here's how I'm trying to do it:
RewriteEngine On
RewriteLog /tmp/rewrite.log
RewriteLogLevel 9
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.html$ $1.shtml
But it doesn't work. This _always_ rewrites the URL. The log says this:
(2) init rewrite engine with request uri /index.html
(3) applying pattern '^(.*)\.html$' to uri '/index.html'
(4) RewriteCond: input='/index.html' pattern='!-f' => matched
(2) rewrite /index.html -> /index.shtml
(2) local path result: /index.shtml
(2) prefixed with document_root to
/var/www/www.slamb.org/root/index.shtml
(1) go-ahead with /var/www/www.slamb.org/root/index.shtml [OK]
The index.html does exist. The full path is
/var/www/www.slamb.org/root/index.html.
Am I doing something wrong, or is this a bug? I've also tried using a
couple different conditions:
RewriteCond %{REQUEST_FILENAME} !-F
RewriteCond %{REQUEST_URI} !-U
They say different things in the log, but they either pass or fail _all_
the time, not based on whether there actually is a .html file present.
The -F check says this:
...
(5) RewriteCond file (-F) check: path=/index.html ->
file=/index.html status=200
(4) RewriteCond: input='/index.html' pattern='!-F' => matched
...
Status 200 means the file was found, right? So why did a !-F match?
And the -U check says this:
...
(5) RewriteCond URI (-U) check: path=/index.html -> status=200
(4) RewriteCond: input='/index.html' pattern='!-U' => not-matched
...
That's correct. But when I try it with a page where the .html doesn't
exist and the .shtml does:
...
(5) RewriteCond: URI (-U) check: path=/test.html -> status=200
(4) RewriteCond: input='/test.html' pattern='!-U' => not-matched
...
Why was the status 200? That file does not exist. (Does it attempt to
apply these rules recursively?)
--
Scott Lamb
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: mod_rewrite: Rewriting .html to .shtml if no .html exists
Posted by "Matus \"fantomas\" Uhlar" <uh...@fantomas.sk>.
-> I'm trying to make .html URLs work whether a page is preprocessed with
-> SSI or not. (While not invoking the overhead of pre-processing all .html
-> documents.)
it would be probably easier to process all .html with mod_includes, wouldn't
it?
--
Matus "fantomas" Uhlar, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I don't wish to receive spam to this address.
Varovanie: Nezelam si na tuto adresu dostavat akukolvek reklamnu postu.
Support bacteria - they're the only culture some people have.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org