简体   繁体   English

使用.htaccess重命名.php文件.html?

[英]using .htaccess to rename .php files .html?

just wondering if there will be any problems renaming .php files .html files via .htaccess? 只是想知道通过.htaccess重命名.php文件.html文件是否会有任何问题? Our existing site is html and I want to update the pages with dynamic php pages, but people have links saved to the existing html site. 我们现有的网站是html,我想用动态php页面更新页面,但是人们已经将链接保存到现有的html网站。 If this isn't possible, is my only way to create html pages with iframes to wrap the php pages in? 如果无法做到这一点,我是否是使用iframe创建html页面来包装php页面的唯一方法?

thanks :) 谢谢 :)

It is not renaming the php file to html, but just redirect the file use html extension to php files. 它不是将php文件重命名为html,而只是将使用html扩展名的文件重定向到php文件。

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f        # don't apply to the existing html files
RewriteRule ^([^.]+)\.html$ /$1\.php [QSA,L]  # QSA means combine query string.

i believe 我相信

RewriteEngine on
RewriteRule ^(.*)\.html $1\.php

should work for your needs (untested) 应该可以满足您的需求(未经测试)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM