On 18/05/2013 10:39 AM, "Don Edmondson" <don.edmond...@kg-enterprises.com> wrote: > > {hope I am doing this right!} > I rewrote many of my pages for SSI (to use 'standard' headers and footers) > but left the original .html files in situ. This was fine for a while - but I > find I am still getting a lot of hits on the .html files so decided to do > something about it... > Enter .htaccess and mod_rewrite. Struggled for a while but then accidently > modified the .htaccess file - and made the rewrites work?? > What I wanted to do was wherever I had a .shtml file, any request for the > .html version would be rewritten to .shtml - but I still have some files > that are ONLY .html so didn't want these rewritten - simple enough (?) - > check if .shtml exists and if yes rewrite uri - so my .htaccess looked > like... > > RewriteEngine on > RewriteRule ^index\.html$ index.shtml [PT]
> RewriteCond $1.shtml -f This line doesnt make sense. What is $1 doing there what is it referencing? > RewriteRule ^(kgp[a-z0-9]*)\.html$ $1.shtml [PT] > > i.e. always rewrite index.html to index.shtml then for any files like > kgp[something].html check if kgp[something].shtml exists and if yes then > rewrite URI... > > ...but this doesn't work - the .html version of the file gets passed > through????? > > The accidental edit on .htaccess however gave me > > RewriteEngine on > RewriteRule ^index\.html$ index.shtml [PT] > RewriteCond $1.shtml !-f > RewriteRule ^(kgp[a-z0-9]*)\.html$ $1.shtml [PT] > > i.e. I negated the RewriteCond with '!-f' - and the rewrite works as I want > ---- > > ---but this is counter-intuitive?? - to me that RewriteCond reads as 'Check > that kgp[something].shtml DOES NOT exist and if it doesn't then rewrite the > URI to kgp[something].shtml. > > I have done traces of both versions and the behaviour is exactly as I > describe above - > > Can someone please explain where my thinking is going wrong (all examples > I've looked at, everywhere, and also the .htaccess on my live website would > suggest that the first version of the .htaccess is correct - but the testing > says otherwise - but I certainly don't want to implement this changed > .htaccess on the live website until I understand what is happening :( )? > > Thanks and Regards > > Don Edmondson. > > > 1 Osborne Close, Camberley, Surrey, GU16 9YD > m: 07747 024 712 > t: 01252 642 626 > w: http://www.kg-enterprises.com > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org > For additional commands, e-mail: users-h...@httpd.apache.org >