Apache .htaccess隐藏.php和.html扩展

Bla*_*zer 2 apache .htaccess mod-rewrite rewrite url-rewriting

我应该添加哪些行以从网站中删除扩展名.html.php扩展名?

我仅将其用于此.html部分:

RewriteEngine on

RewriteBase /
RewriteCond %{http://jobler.ro/} !(\.[^./]+)$
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule (.*) /$1.html [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+)\.html\ HTTP
RewriteRule ^([^.]+)\.html$ http://jobler.ro/$1 [R=301,L]
Run Code Online (Sandbox Code Playgroud)

但我需要将两个文件类型扩展名从同一域中隐藏。

小智 5

我知道它来不及回答,但我给出了它,因为它对某人可能有用:)

#Remove php extension
    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME}\.php -f 
    RewriteRule ^(.*)$ $1.php

#Remove html extension
    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME}\.html -f 
    RewriteRule ^(.*)$ $1.html
Run Code Online (Sandbox Code Playgroud)

这将从您的文件中删除php和html扩展名,并且运行完美。