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?
As you can see, you can use any HTML you want without doing anything special or extra in your PHP file, as long as it's outside and separate from the PHP tags. In other words, if you want to insert PHP code into an HTML file, just write the PHP anywhere you want (so long as they're inside the PHP tags).
htaccess is a configuration file for use on web servers running on the web apache server software. when a . htaccess file is placed in a directory which in turn loaded via the Apache web server, then the . htaccess file detected and executed by the Apache server software.
PHP is a scripting language | HTML is a markup language. PHP code is executed on the server | HTML code is parsed by the client browser. PHP creates dynamic web pages | HTML creates static web pages. PHP can access a database | Database cannot be accessed using HTML.
Create a .htaccess file at the root of your website and add this line:
[Apache2 @ Ubuntu/Debian: use this directive]
AddType application/x-httpd-php .html .htm
Or, from comment below:
AddType application/x-httpd-php5 .html .htm
If your are running PHP as CGI (probably not the case), you should write instead:
AddHandler application/x-httpd-php .html .htm
In My Godaddy Server the following code worked
Options +ExecCGI AddType application/x-httpd-php .php .html AddHandler x-httpd-php5 .php .html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With