htacces隐藏PHP和HTML的一些推广 [英] htacces to hide both php and html extentions

查看:207
本文介绍了htacces隐藏PHP和HTML的一些推广的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

建议立即进行删除我加入什么行删除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]

这篇关于htacces隐藏PHP和HTML的一些推广的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆