I want to convert .php
extension to .html
extension using .htaccess
rules
我想使用.htaccess规则将.php扩展名转换为.html扩展名
Is this something I can do, and if so, how?
这是我可以做的事情,如果是这样,怎么样?
2 个解决方案
#1
10
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php [nc]
Uses mod_rewrite. $1 indicates first part of the regex and [nc] means not case sensitive.
使用mod_rewrite。 $ 1表示正则表达式的第一部分,[nc]表示不区分大小写。
You can take a look at this article: http://roshanbh.com.np/2008/02/hide-php-url-rewriting-htaccess.html
你可以看一下这篇文章: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
3
Maybe try
也许试试吧
RewriteCond %{REQUEST_FILENAME} =-f
RewriteRule ^(.*)\.php$ $1.html [NC,L]
RewriteRule ^(.*)\.html$ $1.php [NC,L]
#1
10
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php [nc]
Uses mod_rewrite. $1 indicates first part of the regex and [nc] means not case sensitive.
使用mod_rewrite。 $ 1表示正则表达式的第一部分,[nc]表示不区分大小写。
You can take a look at this article: http://roshanbh.com.np/2008/02/hide-php-url-rewriting-htaccess.html
你可以看一下这篇文章: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
3
Maybe try
也许试试吧
RewriteCond %{REQUEST_FILENAME} =-f
RewriteRule ^(.*)\.php$ $1.html [NC,L]
RewriteRule ^(.*)\.html$ $1.php [NC,L]