Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的服务器上有一大堆 .shtml 文件,这些文件已经过时,并且已被替换为具有更新内容的文件的 php 版本。新的 php 文件的名称已被保留,例如。buttonClass.shtml 在同一目录中有一个名为 buttonClass.php 的等效文件。我的服务器正在使用 CPanel 和 Apache 是否有一种简单的方法可以将某个目录中的所有 .shtml 文件重定向到同一目录中同名但扩展名为 .php 的文件?
你可以使用 htaccess 来做到这一点。(该文件需要在根目录中)
RewriteEngine on RewriteRule ^(.*)\.shtml$ $1.php
请注意,我没有测试过这个