gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 23:55:30 27 4
gpt4 key购买 nike

我应该添加哪些行来删除 .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]

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

最佳答案

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

#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 扩展名并完美运行。

关于Apache .htaccess 隐藏 .php 和 .html 扩展名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15591251/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com