doubian0284
doubian0284
2015-05-11 08:50

用.htaccess重写php的html文件

已采纳

I need help with converting html with php .

So far My code is

RewriteEngine on 
RewriteRule ([a-z]+).html /$1.php 

This is working fine. but some real html pages have php scripts ,that doesnt run. how to fix this? thanks

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • douduan5753 douduan5753 6年前

    You can use AddHandler directive to change the mime type of a file

    Add the following line to your htaccess file

    AddHandler application/x-httpd-php .html
    

    Now all your html files will work as php.

    点赞 评论 复制链接分享
  • dtlh12053 dtlh12053 6年前

    Try this:

    RewriteEngine On
    RewriteRule ^(.*)\.html$ $1.php [L]
    
    点赞 评论 复制链接分享