如何通过添加无扩展名的文件名来隐藏PHP的使用


How to hide PHP usage by adding extension-less file names?

我不想让其他人知道我在使用PHP。有没有一种方法可以通过更改.htaccess来隐藏它(有点像使用无扩展名的文件名)?

这取决于您的web服务器
对于Apache,您应该使用mod_rewrite

希望它能帮助你

RewriteEngine On
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://example.com/folder/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)'.php([#?][^' ]*)?' HTTP/
RewriteRule ^(.+)'.php$ http://example.com/folder/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]