问题
i want server requests without .php ending to be handled like they had .php. for example http://example.com/exampleSite is requested by the user. How can i use a rewrite rule to handle it like it was requested as http://example.com/exampleSite.php? I do not want to use .htaccess (as it is recommended to put rewrite rules into a directory block inside the apache vhost config. And i only want this to affect my php files in the root directory.
The following config unfortunately does not work.
<VirtualHost *:80>
DocumentRoot /var/www/examplesite
<Directory /var/www/examplesite>
IndexIgnore * # prevent directory listing
DirectoryIndex index.php
Options FollowSymLinks MultiViews
AllowOverride All
Require all granted
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]
</Directory>
ErrorLog /xvar/xlog/error.log
CustomLog /xvar/xlog/access.log combined
来源:https://stackoverflow.com/questions/43967770/mod-rewrite-handle-url-request-without-php-extension