How do I rewrite .php to .html using .htaccess rules?

纵然是瞬间 提交于 2019-12-22 05:14:19

问题


I want to convert .php extension to .html extension using .htaccess rules

Is this something I can do, and if so, how?


回答1:


RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php [nc]

Uses mod_rewrite. $1 indicates first part of the regex and [nc] means not case sensitive.

You can take a look at this article: http://roshanbh.com.np/2008/02/hide-php-url-rewriting-htaccess.html

EDIT: Removed a line. You do not need that I think. Also, commented on what I did.




回答2:


Maybe try

RewriteCond %{REQUEST_FILENAME} =-f
RewriteRule ^(.*)\.php$ $1.html [NC,L]

RewriteRule ^(.*)\.html$  $1.php [NC,L]


来源:https://stackoverflow.com/questions/2878559/how-do-i-rewrite-php-to-html-using-htaccess-rules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!