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 my Apache server?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Is there a way to play audio on a mobile browser w
In My Godaddy Server the following code worked
I'm using PHP7.1 running in my Raspberry Pi 3.
In the file
/etc/apache2/mods-enabled/php7.1.conf
I added at the end:This is in edition to all other right answers:
If you are not able to find the correct Handler, Simply create a .php file with the following contents:
and run/open this file in browser.
Use this output in .htaccess file
Create a .htaccess file at the root of your website(usually a folder named public_html or htdocs on linux servers) and add this line:
Example
Important Note:
If you see blank page or
Notice: Undefined index: REDIRECT_HANDLER
Try default in
.htaccess
You may also use the H or T flag of mod_rewrite to force all .html files to be parsed by php handler :
using H (Handler) flag:
using T (Type) flag :
Or you can add more extensions to the rule pattern seprated by a pipe | that you want to be parsed by php handler
ex :
the example above will change the mime type of files that end with .html , .htm , .txt , .foo to php.
Note : on some servers you will have to change php5 to php to get this example to work in handler string:
Change it
to
You need to add the following line into your Apache config file:
You also need two other things:
Allow Overridding
In
your_site.conf
file (e.g. under/etc/apache2/mods-available
in my case), add the following lines:Enable Rewrite Mod
Run this command on your machine:
After any of those steps, you should restart apache:
here put this in your .htaccess
more info on this page