cancel
Showing results for 
Search instead for 
Did you mean: 

More mod_rewrite questions (normal webspace not ccgi)

oliverb
Grafter
Posts: 606
Registered: ‎02-08-2007

More mod_rewrite questions (normal webspace not ccgi)

OK so I'm trying to make a more advanced mod_rewrite configuration, and I'm experiencing a few false starts. For example I'd really like to use "Rewritecond" with the
%{REQUEST_FILENAME}  variable and -f option as I've read that I can make it check for a file and only carry out the rewrite if the file exists.
Unfortunately the path in %{REQUEST_FILENAME} is much longer than the path in the url, it seems to be the absolute path, and as such I can't use tests like
Rewritecond images/%{REQUEST_FILENAME} -f
as %{REQUEST_FILENAME} expands to something like /share/isp/plusnet/www/bu ... and so on
Update...I think this is holding now,
I've changed the Rewritecond to something like
Rewritecond /share/isp/plusnet/allthatstuff/$1 -f
and it seems to work, even though the $1 substitution appears before the expression that uses it.
It still needs some work as the pattern match is a bit squirrely still but its working so it appears that I can have files served from two or more locations
Extracting the full pathname to your webspace is tricky but I found a rule like
RewriteRule ^/?aardvark\.htm /index.htm?%{REQUEST_FILENAME} [L,R]
caused it to be written to the address bar where I could see it.
1 REPLY 1
oliverb
Grafter
Posts: 606
Registered: ‎02-08-2007

Re: More mod_rewrite questions (normal webspace not ccgi)

Can anyone help with writing a regular expression...
I'd like to match filenames that are in the root and don't have an extension.
I think something like /?([^/.]+) might do it, or maybe I need to use a negated Rewritecond rule to say if the name does have a dot in then don't execute the rule.
Somehow any expression I write ending in $ fails to match anything. Do urls have a trailing character after the filename that prevents match-to-eol?