
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 About.php.
This article is written for the scenario where an HTTPD web server has been configured with support for PHP.
The httpd command with the -M flag can be used to determin if the rewrite module is enabled. If rewrite_module is in the list of modules of the following command, then the rewrite_module is enabled.
~]# httpd -M
rewrite_module (shared)
If you have more than one HTTPD conf file, the -f option can be used to point to a specific HTTPD conf file.
~]# httpd -f /path/to/httpd.conf -M
rewrite_module (shared)
In your httpd.conf file (e.g. /etc/httpd/conf/httpd.conf) file, inside of <Directory /var/www>, ensure AllowOverride is set to All.
<Directory /var/www>
AllowOverride All
The ps command can be used to determine if your system is using init or systemd. If PID 1 is init, then you will use the service command. If PID 1 is systemd, then you will use the systemctl command.
If your system is using systemd, use the systemctl command to restart httpd.
systemctl restart httpd
If your system is using init, use the service command to restart httpd.
service httpd restart
Use the apachectl configtest command can be used to verify the configuaration of HTTPD is OK.
~]# apachectl configtest
Syntax OK
Create the .htaccess file.
~]# touch /var/www/html/.htaccess
Edit the .htaccess file and add the following.
RewriteEngine On
RewriteRule ^About$ About.php [NC]
Now, you should be able to get your About.php page without having to include the .php extension.
Did you find this article helpful?
If so, consider buying me a coffee over at