.htaccess - Remove From .PHP from the URL? -


this .htaccess file:

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

when user goes http://local/home, works fine, if user goes http://local/home.php, .php stays there, doesn't redirect page without .php, don't mark duplicate have researched it.

you don't have rule redirects request php extension redirect without it. that's why stays there. because you've added rule internally rewrite request missing php extension doesn't mean magically happens in other direction. @ top of rules need match against actual request , redirect browser when requests php file:

rewritecond %{the_request} ^(get|head)\ /(.+)\.php(\?|\ ) rewriterule ^ /%2 [l,r=301] 

more:

just matter of recognizing rule 1 thing asked do, match pattern against uri, , rewrite/redirect target.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -