FreeKB - How to hide the PHP extension in HTTPD
How to hide the PHP extension in HTTPD

Home > Search > How-to

By default, the .php extension will show in a web browsers address bar. For example, if you've a page named About.php, the address bar will show


Ensure the rewrite module is enabled. If rewrite_module is in the list of modules of the following command, then the rewrite_module is enabled.

[root@server1 ~]# httpd -M
. . .
rewrite_module (shared)


In the /etc/httpd/conf/httpd.conf file, inside of <Directory /var/www>, ensure AllowOverride is set to All.

<Directory /var/www>
. . .
AllowOverride All


Restart HTTPD, and ensure HTTPD is active and running.

[root@server1 ~]# systemctl restart httpd
[root@server1 ~]# systemctl status httpd


Use the apachectl configtest command can be used to verify the configuaration of HTTPD is OK.

[root@server1 ~]# apachectl configtest
. . .
Syntax OK


Create the .htaccess file.

[root@server1 ~]# touch /var/www/html/.htaccess


Edit the .htaccess file, and add the following.

RewriteEngine On
RewriteRule ^about$ about.php [NC]


Now, .php will no longer be displayed.


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 76067 in the box below so that we can be sure you are a human.