php - Plain text in Apache rewriteCond testStr -


i have following set of apache rewritecond/rewriterule:

rewritecond $1.php -f rewriterule ^(.+)/$ index.php?id=$1 

what want check whether keyword in url actual file, , keyword name of file, without .php extension. example, if url www.example.com/foo/ , file foo.php exists, redirect www.example/index.php?id=foo.

documentation on rewritecond says:

teststring string can contain following expanded constructs in addition plain text:

...and lists constructs. so, using reference "$1" , add plain text ".php" see if pattern matches actual php file. doesn't work. examples found use "expanded constructs", none use plain text in test stiring. can used @ all? how?

you need provide full path check existence of file using -f. replace rule this:

rewritecond %{request_filename} !-d rewritecond %{document_root}/$1\.php -f [nc] rewriterule ^(.+?)/?$ /$1.php [l] 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -