How to show uploaded php file as plain text instead of executing it in wordpress
-
Edit a testme.php file in /tmp.
<?php
echo “test”;
?>
Edit a new post titled test and upload file /tmp/testme.php ,pubish it with url https://home.local/wp/?p=4785 (home.local point to 127.0.0.1)I want to see the content in testme,type
https://home.local/wp/?p=4785
.
test post in my wordpress
To click testme url in test post.
click
Go on to click testme, i got the executing result of testme.php in webpage.test
My requirements :
1.just click testme in test post for one time.
2.show the testme.php as plain text ,<?php echo "test"; ?>
instead of the result of executing testme.php.
I make a configuration according some material show php file as plain text in apache.
sudo vim /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80> ServerName www.home.local ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory /var/www/html> Options Indexes FollowSymLinks MultiViews AllowOverride All allow from all php_flag engine off AddType text/plain php </Directory> </VirtualHost>
Reboot apache2(build in debian).
sudo systemctl restart apache2
To open the post https://home.local/wp/?p=4785,i got the following output in webpage:
<?php /** * Front to the WordPress application. This file doesn't do anything, but loads * wp-blog-header.php which does and tells WordPress to load the theme. * * @package WordPress */ /** * Tells WordPress to load the WordPress theme and output it. * * @var bool */ define('WP_USE_THEMES', true); /** Loads the WordPress Environment and Template */ require( dirname( __FILE__ ) . '/wp-blog-header.php' );
- The topic ‘How to show uploaded php file as plain text instead of executing it in wordpress’ is closed to new replies.