htacces隐藏PHP和HTML的一些推广htacces、PHP、HTML

2023-09-02 09:51:10 作者:青春散场,不诉离殇

建议立即进行删除我加入什么行删除HTML和PHP扩展从我的网站?

What lines shoul I add to remove both html and php extensions from my site ?

我用这个为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]

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

but I need for both file type extensions from the same domain.

推荐答案

您将要测试是否与的.html 的.php文件的存在,然后重定向到这样的文件,如果如此。

You would want to test whether the file with .html or .php exists, and then redirect to such file if so.

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$  $1.html [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$  $1.php [L]

RewriteCond %{REQUEST_URI} .((html)|(php))$
RewriteRule ^(.*).([^.]+)$  $1 [R,L]
 
精彩推荐