我希望能够在我的.htaccess
文件中加入一些内容,以隐藏我的php文件的.php
文件扩展名,这样访问www.example.com/dir/somepage将显示www.example.com/dir/somepage.php。
有没有可行的解决方案?如果这很重要,我的网站使用HTTPS。
这是目前我的.htaccess文件内容:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
ErrorDocument 404 /error/404.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
RewriteCond %{REQUEST_METHOD} !POST
条件,以避免将 POST 请求重定向。 - anubhava