php URL structure /page.php vs /page -
this question has answer here:
- how remove file extension website address? 11 answers
i have build few sites website. end .php. problem if want view page have type in website.com/page.php instead of website.com/page how make happen of main pages? there quick way of doing or have set forwarding of /pages /page.php?
in cases achieved using mvc framework , routing. works in way don't access single .php file single web page show user. every request goes through 1 file , have router define routes , define action controller route invoke, , there choose view file show user. hard explain in few sentances. anyway using mvc nice url-s www.example.com/controller/action/param
now if want remove .php extension files can put in .htaccess file:
rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename}\.php -f rewriterule ^(.*)$ $1.php
but other hiding .php, wont good.
the best thing can read mvc frameworks, routing , front controller pattern, , take there, not nice url-s, there's more gain! , if want hide .php extension use above code.
hope helps!
Comments
Post a Comment