php - .htaccess 重定向到 .php 文件时未加载任何资源(img、js、css)
问题描述
我想将没有扩展名的页面重定向到 php 文件。例如
https://example.com/starrysky/ => https://example.com/starrysky.php
我已经有一个从 HTML 到 PHP 的有效重定向:
https://example.com/starrysky.html正确重定向https: //example.com/starrysky.php。
当我在.htaccess中将.html重定向到.php时,它完美地工作:它将.html重定向到.php,所以我想,用(以斜杠结尾)替换最后一个会重定向到 php ,但这不起作用。.html$
/$
这确实有效
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php
但这不会:
# RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/$ $1.php
在最后一行的斜杠 + 美元前面加上反斜杠将无济于事。并且取消注释上面的 RewriteCond 行也对我没有帮助。
我希望https://example.com/starrysky/重定向到https://example.com/starrysky.php。
确实如此,但没有加载 css、js 和图像,尽管它们是相对于同一个文档根目录的。
解决方案
推荐阅读
- python - 将数据帧写入存储在服务器上的 postgresql 数据库的最快方法是什么?
- r - R闪亮 - 上传后更改文本文件输入
- .net - Windows 10 更新后的 .NET Framework 错误 - 文件丢失
- javascript - 页面加载时在 iframe 上自动点击 3 次
- python-3.x - 如何在 Python 中使用 API 并将数据从一个函数传递到另一个函数
- android-studio - 原因:重复条目:AndroidManifest.xml
- jquery - 在本地 IIS 中启用 Cors
- php - 如何按索引(日期)对以下数组进行排序?
- node.js - 删除整个文档以匹配对象数组中的objectId - MongoDB
- javascript - 如何在函数中发送返回对象