apache - Remove php from url (again!) -


i have seen many posts apologies yet another. have tried read around how works little success: start here .htaccess

rewriteengine on rewritecond %{https} !=on rewriterule ^ https://%{http_host}%{request_uri} [l,r=301]  rewriteengine on rewritecond %{request_filename} !-f rewriterule ^(([^/]+/)*[^.]+)$ /$1.php [l] 

the first sets http https - works .htaccess active. second meant remove .php url - doesn't.

my main question how remove .php each url. second rewrite rule meant doesn't. yes, copied previous question understand syntax means can understand why not working.

so questions are:

  1. can point me decent explanation of syntax rewritecond , rewriterule? have looked number of docs including apache http://httpd.apache.org/docs/current/rewrite/ docs no better off.
  2. and / or why .php removal not work?

a cheeky simple question ... need repeat rewriteengine on or need once?

have (see comments above each rule):

rewriteengine on  # redirect externally http -> https non post data rewritecond %{request_method} !post rewritecond %{https} off rewriterule ^ https://%{http_host}%{request_uri} [l,r=301,ne]  # externally redirect (change url in browser) /dir/file.php /dir/file rewritecond %{request_method} !post rewritecond %{the_request} \s/+(.+?)\.php[\s?] [nc] rewriterule ^ /%1 [r=301,ne,l]  # internally (silent) rewrite /dir/file /dir/file.php rewritecond %{request_filename} !-d rewritecond %{request_filename}.php -f rewriterule ^(.+?)/?$ $1.php [l] 

references


Comments