阿帕奇的.htaccess隐藏两者的.php和.html的一些推广 [英] Apache .htaccess to hide both .php and .html extentions

查看:141
本文介绍了阿帕奇的.htaccess隐藏两者的.php和.html的一些推广的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要补充什么行同时删除的.html 的.php 从我的网站扩展?

What lines should 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 to be hidden 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]

这篇关于阿帕奇的.htaccess隐藏两者的.php和.html的一些推广的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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