.htaccess 用于显示 .html 文件

发布于 2024-08-27 14:34:35 字数 352 浏览 4 评论 0原文

我在“test”文件夹中有三个文件,

one.php
two.php
print.html

并且在同一文件夹中有 .htaccess 文件,

RewriteEngine On
RewriteBase /test/
RewriteRule ^(.+)\.html$ $1\.php [L]

如果我们在浏览器中获取 print.html,则会出现错误,因为 .htaccess 文件, 因为没有“print.php”页面,

我们如何解决这个问题,通过修改 .htaccess 文件。这样在获取 print.html 时,它应该显示在浏览器中

I have three files in a folder 'test'

one.php
two.php
print.html

And i have .htaccess file in the same folder

RewriteEngine On
RewriteBase /test/
RewriteRule ^(.+)\.html$ $1\.php [L]

if we take the print.html in browser , there will be error , because of .htaccess file,
for there is no 'print.php' page

How can we solve it , by modifing the .htaccess file. So that while taking the print.html, it should display in the browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

衣神在巴黎 2024-09-03 14:34:35

试试这个。

RewriteEngine On
RewriteBase /test/
#If the request is for a file that exists already on the server, the "$1\.php" rule isn't served. 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.html$ $1\.php [L]

Try this.

RewriteEngine On
RewriteBase /test/
#If the request is for a file that exists already on the server, the "$1\.php" rule isn't served. 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.html$ $1\.php [L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文