Using .htaccess to make all .html pages to run as .php files?

前端 未结 16 1724
忘了有多久
忘了有多久 2020-11-22 00:41

I need to run all of my .html files as .php files and I don\'t have time to change all of the links before our presentation tomorrow. Is there any way to \"hack\" this with

16条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 01:18

    You need to add the following line into your Apache config file:

    AddType application/x-httpd-php .htm .html
    

    You also need two other things:

    1. Allow Overridding

      In your_site.conf file (e.g. under /etc/apache2/mods-available in my case), add the following lines:

      ">
          AllowOverride All
      
      
    2. Enable Rewrite Mod

      Run this command on your machine:

      sudo a2enmod rewrite 
      

      After any of those steps, you should restart apache:

      sudo service apache2 restart
      

提交回复
热议问题