Apache .htaccess 隐藏 .php 和 .html 扩展名 [英] Apache .htaccess to hide both .php and .html extentions

查看:33
本文介绍了Apache .htaccess 隐藏 .php 和 .html 扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我只将它用于 .html 部分:

I use this for just the .html part:

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.

推荐答案

我知道回答晚了,但我还是给了它,因为它对某人有用 :)

I know its late to answer but I giving it since it can be useful to someone :)

#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

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

This will remove both php and html extension from your files and works perfectly.

这篇关于Apache .htaccess 隐藏 .php 和 .html 扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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