我正在/ var / www / html / app内运行一个php Web应用程序,我试图修改apache配置,以便从浏览器中隐藏.php文件扩展名。 我已经阅读了关于堆栈溢出的其他多个答案,但是没有一种解决方案适合我。
我的应用程序位于/var/www/html/app
我的网站使用HTTPS,而我一直在修改的配置文件是:
/etc/apache2/sites-enabled/application-ssl.conf
conf文件的内容为:
<VirtualHost *:443>
# The ServerName directive sets the request scheme,hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts,the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However,you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8,...,trace1,debug,info,notice,warn,# error,crit,alert,emerg.
# It is also possible to configure the loglevel for particular
# modules,e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName myapplication.com
DocumentRoot /var/www/html
SSLEngine on
SSLCertificateFile /etc/ssl/myapplication_com.crt
SSLCertificateKeyFile /etc/ssl/private/myapplication.com/myapplicationcom.key
SSLCertificateChainFile /etc/ssl/myapplication_com.ca-bundle
# For most configuration files from conf-available/,which are
# enabled or disabled at a global level,it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
SecRuleEngine On
<IfModule mod_headers.c>
<Directory />
Header always set X-XSS-Protection "1; mode=block"
Header always set x-Frame-Options "SAMEORIGIN"
Header always set X-Content-Type-Options "nosniff"
Header always set strict-transport-security "max-age=31536000; includeSubDomains"
Header always set Referrer-Policy "strict-origin"
</Directory>
</IfModule>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<Directory /var/www/html/app>
Options +MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Directory>
当前我添加了:
Options +MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,deny
allow from all
因为这似乎是apache2的最推荐解决方案。
我不在/var/www/html/app
中使用.htaccess文件,并且
启用了Mod Rewrite
我看不到我的Web应用程序中的任何更改,并且当我访问没有php的文件时,在日志中出现404错误和以下错误:
AH00687: Negotiation: discovered file(s) matching request: /var/www/html/app/betfinder (None could be negotiated).
如何修改我的配置以使其正常工作?