Hide or Change page extension with mod_rewrite

2019-09-10 23:59发布

问题:

how can i change all my php page to show as html page in the browser ?
What will be the file name when they will save a x.php file ?

回答1:

Try putting the following in a .htaccess file at the main directory of your site (public_html or www), or httpd.conf (or similar) if you aren't on shared hosting and have root access to the server:

RewriteEngine On
RewriteRule ^(.*)\.html$ $1.php

When someone tries to save the page, it will save as .html (they will never know it was really a .php file!)